Advertisement
Guest User

Untitled

a guest
Oct 28th, 2013
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)viewDidLoad
  2. {
  3.     [super viewDidLoad];
  4.     // Do any additional setup after loading the view, typically from a nib.
  5.     UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
  6.     _collectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(130, 100, 780, 1024) collectionViewLayout:layout];
  7.     _collectionView.autoresizesSubviews= YES;
  8.     [_collectionView setDataSource:self];
  9.     [_collectionView setDelegate:self];
  10.     _collectionView.backgroundColor = [UIColor clearColor];
  11.    
  12.     [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
  13.    
  14.     [self.view addSubview:_collectionView];
  15. /*
  16.     for (int i=0; i<12; i+=2) {
  17.         NSIndexPath *index = [NSIndexPath indexPathForItem:i inSection:0];
  18.         NSIndexPath *index1 = [NSIndexPath indexPathForItem:i+1 inSection:0];
  19.         [_collectionView moveItemAtIndexPath:index toIndexPath:index1];
  20.     }
  21.     for (int i=2; i<12; i+=2) {
  22.         NSIndexPath *index = [NSIndexPath indexPathForItem:i inSection:0];
  23.         NSIndexPath *index1 = [NSIndexPath indexPathForItem:i+1 inSection:0];
  24.         [_collectionView moveItemAtIndexPath:index toIndexPath:index1];
  25.     }
  26.      */
  27.    
  28. }
  29.  
  30. - (void)didReceiveMemoryWarning
  31. {
  32.     [super didReceiveMemoryWarning];
  33.     // Dispose of any resources that can be recreated.
  34. }
  35. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
  36. {
  37.     return 12;
  38. }
  39. -(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
  40. {
  41.     return 1;
  42. }
  43. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  44. {
  45.     UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
  46.     UIView *headertitle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 375, 20)];
  47.     UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
  48.     titlelabel.text = [NSString stringWithFormat:@"graphtitle%d",indexPath.row];
  49.     titlelabel.textColor = [UIColor blackColor];
  50.     titlelabel.font = [UIFont fontWithName:@"Knewave" size:15.0f];
  51.     titlelabel.backgroundColor = [UIColor clearColor];
  52.     [headertitle addSubview:titlelabel];
  53.     headertitle.backgroundColor = [UIColor whiteColor];
  54.     UIWebView *web = [[ UIWebView alloc]initWithFrame:CGRectMake(0, 20, 375, 150)];
  55.     NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
  56.     NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
  57.     web.scalesPageToFit = YES;
  58.     [web loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]];
  59.     UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
  60.     button1.backgroundColor = [UIColor clearColor];
  61.     button1.frame = CGRectMake(320, 3, 50, 17);
  62.     [button1 setTitle:@"view" forState:UIControlStateNormal];
  63.    
  64.     [headertitle addSubview:button1];
  65.     headertitle.backgroundColor = [UIColor grayColor];
  66.    
  67.     [cell addSubview:headertitle];
  68.     [cell addSubview:web];
  69.    
  70.     cell.layer.shadowColor = [[UIColor blackColor]CGColor];
  71.     cell.layer.shadowOffset = CGSizeMake(20, 20);
  72.     cell.layer.borderColor = [[UIColor blackColor] CGColor];
  73.     cell.layer.borderWidth =1;
  74.     //cell.alpha = 0;
  75.    
  76.    
  77.    
  78.     return cell;
  79. }
  80. -(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  81. {
  82.     return 10;
  83. }
  84. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  85. {
  86.     return CGSizeMake(377, 172);
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement