UICollectionViewFlowLayout* layout = [[UICollectionViewFlowLayout alloc] init];/**< 布局 */
[layout setMinimumLineSpacing:0];//最小行距
[layout setMinimumInteritemSpacing:0];//最小列距
[layout setItemSize:CGSizeMake(width, height-80)];
[layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];//设置滚动方向为水平方向
collectionview属性:
pagingEnabled //是否分页
ShowsHorizontalScrollIndicator 是否显示水平方向滑条
showsVerticalScrollIndicator 是否显示竖直方向滑条
设置collectionview的头部试图:
1、设置头部视图的size: layout.headerReferenceSize = CGSizeMake(kWidth, kHeight / 4);
2、注册头部试图: [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"header"];
3、在代理方法里面实心头部视图:
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
if (kind == UICollectionElementKindSectionHeader) {
self.headerView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"header" forIndexPath:indexPath];
return self.headerView;
}
return nil;
}
collectionView的属性
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Demo地址:https://github.com/Rogue24/JPCustomScrollPageSize ...
- 补一下这个文章的资源,我只后有找到了两种其他人的实现,加上我的实现一共三种方式(我的最垃圾了,别在意这些细节)然后...
- 在UITableView的Cell里嵌套使用CollectionView场景里,如果在点击CollectionVi...
- 本节知识点 存储属性 常量存储属性 类和结构体常量与存储属性的关系 延迟存储(懒加载)属性 计算属性 只读计算属性...
- Xamarin XAML语言教程构建ControlTemplate控件模板 控件模板ControlTemplate...