UICollectionView

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

解决方法以下:io

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

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

    return top;top

}view

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

因此咱们只需设定cell的大小  cell之间的间距天然就算出来了co

相关文章
相关标签/搜索