collectionView代理方法快速设置cell大小上下左右间隔

来源:互联网 发布:华而不实为所欲为知乎 编辑:程序博客网 时间:2024/06/09 15:45

#define JianGe 25

#define GeShu 4

#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)

#define Screenheight ([UIScreen mainScreen].bounds.size.height)


//定义每个UICollectionView的大小

- ( CGSize )collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {

    return CGSizeMake((ScreenWidth -JianGe*(GeShu+1)) /GeShu, (ScreenWidth -JianGe*(GeShu+1)) /GeShu );

}


//定义每个UICollectionView的边距

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

    return UIEdgeInsetsMake (JianGe , JianGe ,JianGe , JianGe );

}

//设置水平间距 (同一行的cell的左右间距)

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {

    returnJianGe;

}

//垂直间距 (同一列cell上下间距)

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {

    returnJianGe;

}

0 0
原创粉丝点击