美文网首页
UICollectionView + UIKit Dynamic

UICollectionView + UIKit Dynamic

作者: iPhone | 来源:发表于2016-10-08 14:46 被阅读19次

    一、Demo1

    @implementation ASHCollectionViewController
    
    static NSString * CellIdentifier = @"CellIdentifier";
    
    -(void)viewDidLoad 
    {
        [super viewDidLoad];
        [self.collectionView registerClass:[UICollectionViewCell class] 
                forCellWithReuseIdentifier:CellIdentifier];
    }
    
    -(UIStatusBarStyle)preferredStatusBarStyle 
    {
        return UIStatusBarStyleLightContent;
    }
    
    -(void)viewDidAppear:(BOOL)animated 
    {
        [super viewDidAppear:animated];
        [self.collectionViewLayout invalidateLayout];
    }
    
    #pragma mark - UICollectionView Methods
    
    -(NSInteger)collectionView:(UICollectionView *)collectionView 
        numberOfItemsInSection:(NSInteger)section 
    {
        return 120;
    }
    
    -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView 
                     cellForItemAtIndexPath:(NSIndexPath *)indexPath 
    {
        UICollectionViewCell *cell = [collectionView 
            dequeueReusableCellWithReuseIdentifier:CellIdentifier 
                                      forIndexPath:indexPath];
    
        cell.backgroundColor = [UIColor orangeColor];
        return cell;
    }
    
    @end
    

    相关文章

      网友评论

          本文标题:UICollectionView + UIKit Dynamic

          本文链接:https://www.haomeiwen.com/subject/njbbsttx.html