首页 > 其他 > 详细

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

时间:2018-01-17 15:16:29      阅读:289      评论:0      收藏:0      [点我收藏+]
#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;
}

参考链接:collectionView代理方法快速设置cell大小上下左右间隔

 

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

原文:https://www.cnblogs.com/mnstar/p/8302809.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!