zoukankan      html  css  js  c++  java
  • UICollectionView

        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];

        CGFloat itemWidth = (kScreenWidth - 30) / 2;

        CGFloat itemHeight = 260;

        layout.itemSize = CGSizeMake(itemWidth, itemHeight);

        layout.minimumInteritemSpacing = 10;// 左右的最小距离

        layout.minimumLineSpacing = 10;// 上下的最小距离

        layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;// 水平滑动

        layout.footerReferenceSize = CGSizeMake(kScreenWidth, 150);

        layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);

        

        UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) collectionViewLayout:layout];

        collection.backgroundColor = RGB(240, 241, 242);

        [collection registerClass:[UICollectionView class] forCellWithReuseIdentifier:@"cell"];

        collection.delegate = self;

        collection.dataSource = self;

        [self.view addSubview:collection];

     

     

    #pragma UICollectionView dataSource

     

    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{

        

        return 5;

    }

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

        

        static NSString *identify = @"collectionCell";

        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify forIndexPath:indexPath];

        if (!cell) {

            cell = [[UICollectionView alloc] init];

        }

        cell.backgroundColor = [UIColor whiteColor];

        return cell;

    }

  • 相关阅读:
    【数据结构】算法 Minimum Remove to Make Valid Parentheses 移除无效的括号
    【数据结构】算法 Remove Outermost Parentheses 删除最外层的括号
    【数据结构】算法 Valid Parentheses 有效的括号
    for嵌套的那些事
    i++与++i的区别
    初次接触JS 2017/11/27
    鼠标经过图片变大
    bootstrap使用
    ajax的应用原理及基本用法
    ajax实例代码及效果
  • 原文地址:https://www.cnblogs.com/tom2015010203/p/5230687.html
Copyright © 2011-2022 走看看