您的位置:首页 > 其它

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

2017-03-20 12:33 393 查看
#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 {

    return
JianGe;

}

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

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

    return
JianGe;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: