UICollectionView
2015-08-19 23:21
621 查看
UICollectionView是UITableView的升级版本,对于UITableView来说系统提供的cell上存在一些显示内容,但是UICollectionView的cell干干净净,因此UICollectionView想显示内容必须使用自定义Cell.UITableView只支持单列竖直滚动,UICollectionView可以支持多列并且可以控制滚动方向.//UICollectionViewDelegateFlowLayout//注意:在使用系统提供的布局时,不用设置该协议的代理人,默认直接设置delegate和DataSource
//创建网格化布局 UICollectionViewFlowLayout *flowLayout = [[[UICollectionViewFlowLayout alloc]init]autorelease];使用瀑布流比较好用,不过这个样式类是创建UICollectionView必备的.
//修改背景颜色(默认背景颜色黑色) self.collectionView.backgroundColor = [UIColor whiteColor];
//设置cell的尺寸(由布局完成) flowLayout.itemSize = CGSizeMake((self.view.frame.size.width-30)/2, 100);如果是瀑布流的话注意是itemWidth
//设置每个分区的边框范围 <pre name="code" class="objc"> flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
//设置最小列间距,最小行间距 这个是最小的哦,如果间距比<span style="font-family: Times;">minimum</span>大,就按间距来,如果间距比<span style="font-family: Times;">minimum</span>小,就按minimum的值.flowLayout.minimumInteritemSpacing = 5;flowLayout.minimumLineSpacing = 10;set = UIEdgeInsetsMake(10, 10, 10, 10);//专门返回每个分区的页眉或者是页脚- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString*)kind atIndexPath:(NSIndexPath *)indexPath{if (kind ==UICollectionElementKindSectionHeader) {HeaderCollectionReusableView *header = [collectionViewdequeueReusableSupplementaryViewOfKind:kindwithReuseIdentifier:@"header"forIndexPath:indexPath];header.textLabel.text =@"萌娃";return header;}else{return nil;}}
相关文章推荐
- Longest Increasing Common Subsequence (LICS)
- POJ - 1679 The Unique MST(次小生成树)
- NSString/NSMutableString/NSNumber/NSValue
- hdu 5400 Arithmetic Sequence
- hdu 2817 A sequence of numbers(快速幂)
- 动态改变UITabBarController的菜单文字
- easyui------显示隐藏列功能
- UIView.animateWithDuration 没有动画过渡效果直接跳到最后
- UIScrollView滚动时隐藏底部导航栏问题
- LightOJ 题目1427 - Substring Frequency (II)(AC自动机)
- 实现UITableView循环利用
- STL使用:deque双端队列
- 8.18 [LeetCode 52] N-Queens II
- UI_04 事件处理
- uva 11248 Frequency Hopping (最大流)
- HDU 3836--Equivalent Sets【求有向图最少增加多少边使图强连通 && Scc缩点新建图】
- priority_queue优先队列容器
- UVA 694-The Collatz Sequence
- GUID全球唯一标识
- GUID全球唯一标识