collectionheaderview
来源:互联网 发布:网络卫生直报平台 编辑:程序博客网 时间:2024/06/10 05:11
collectionview不像tableview那样,有tableheaderview
collectionview若想实现collectionviewheaderview就必须实现 viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath方法,通过创建页眉来实现,实现前必须要注册,否侧会crash
设置其他section的高度为0.0001来实现只返回一个页眉
若要修改headrview的属性可以通过代理来实现,但一定要注意,在设置代理人的时候必须将页眉设置成属性,并且将return写在if的外面
if indexPath.section == 0 {
self.headerView = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionHeader, withReuseIdentifier: "header", forIndexPath: indexPath) as! ShopHeaderView
self.headerView.delegate = self
self.headerView.logoPicture.sd_setImageWithURL(NSURL(string: self.shop_logo), placeholderImage: nil)
self.headerView.titleLabel.text = self.shop_name
}
return self.headerView
这样写看起来挺奇葩,但是貌似只有这样才不会出现紊乱
- collectionheaderview
- hdu 1087 Super Jumping! Jumping! Jumping!(LIS)
- 2016.3.21
- 257. Binary Tree Paths
- Linux 进程间通信 ----消息队列
- 约瑟夫环问题
- collectionheaderview
- 环境变量中path不小心删除了
- Linux IO模式
- 错误:“LNK1169找到一个或者多个重定义的符号”
- 文章标题
- 第十五讲--Oracle存储结构:文件
- Widora MT7688 开发板录音放音使用方法
- [Poj 1426] Find The Multiple BFS
- Java基础静态变量、静态方法