UICollectionView

今天想实现一个collectionView的效果: 一行放两个cell  保证cell之间的距离等于左边cell离最左边的距离 右边的cell到最右边的距离

解决方法如下:

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {

    UIEdgeInsets top = {18,10,20,10};

    return top;

}

这个函数是保证collectionview的一个整section离上边 左边 下边 右边的距离  上个函数说明挣个section离上左下右分别为18,10,20,10

所以我们只需设定cell的大小  cell之间的间距自然就算出来了

posted @ 2014-12-28 16:50  二号猎人  阅读(239)  评论(0)    收藏  举报