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;
}
#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;
}
相关文章推荐
- iOS开发小技巧--设置cell左右有空隙,设置分割线的新思路,重写setFrame:让别人在外界无法修改控件的大小
- TextView使用wrap_content设置高度,上下有间隔 去除的方法,两种
- RecyclerView 上下左右四种间距的设置方法
- Android View 上下左右四种间距的设置方法
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- 图片自适应父元素大小,并左右上下居中的css方法
- 图片自适应父元素大小,并左右上下居中的css方法
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- Android 自定义RadioButton 实现文字上下左右方向的图片大小设置
- linux下sqlplus使用光标上下左右方法
- 通过三种方法为apt-get设置http代理服务
- CCProxy代理上网设置方法
- Flex中如何通过borderStyle和borderSides样式设置NumericStepper控件特定边框(上下左右边)的例子
- Flex的RichTextEditor控件中如何利用textAreaStyleName和letterSpacing设置字符间间隔大小的例子
- Windows 7 虚拟内存大小设置方法
- git代理设置及下载方法
- CCProxy代理上网设置方法
- CCProxy代理上网设置方法
- ASP快速获取远程文件大小的方法
- VC中工具栏按钮文字及左右排列设置方法