iOS中UICollectionView添加头视图
参考链接:https://www.jianshu.com/p/ef57199bf34a
找了一堆的博客,写的都少了很重要的一步。
//引入头部视图
-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
UICollectionReusableView *reusableview = nil;
NSLog(@"kind = %@", kind);
if (kind == UICollectionElementKindSectionHeader){ CouponCollHeaderView *headerV = (CouponCollHeaderView *)[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:CellHeadID forIndexPath:indexPath];
headerV.backgroundColor = [UIColor greenColor];
[headerV getSHCollectionReusableViewHearderTitle:@"这是标题"];
reusableview = headerV;
} return reusableview; }
//设置头部高度
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{ return CGSizeMake(SCREEN_WIDTH, CONVER_VALUE(245.5f));
}
剩下的后期整理。
iOS中UICollectionView添加头视图的更多相关文章
- UICollectionview的头视图和尾视图
UITableView有头视图和尾视图,那么UICollectionView有没有头视图和尾视图呢? 答案是有的. 1.新建一个类,必须继承自 UICollectionReusableView. 2. ...
- iOS中 UICollectionView UI_19
UICollectionView 是UITableView加强版 UITableView 和UICollectionView的设计思想: 1.布局: UITableView 的布局可以由UITable ...
- IOS中在自定义控件(非视图控制器)的视图跳转中 代理方法与代码块的比较
//代码块与代替代理的设计方法 我就以在自定义视图中(非视图控制器,不能实现视图控制功能),通过代理和代码块两种方法分别实现视图的跳转,进行对比 首先自定义了一个视图,上面有一个已经注册了得BUtto ...
- IOS中UICollectionView和UICollectionViewController的用法
1.新建一个xib描述UICollectionViewCell(比如DealCell.xib),设置好resuse identifier(比如deal) 2.控制器继承UICollectionView ...
- ios键盘上添加辅助视图
- iOS 中UICollectionView实现各种视觉效果
参考链接:https://www.jianshu.com/p/b3322f41e84c 基础:https://www.jianshu.com/p/d0b034f59020
- iOS - UICollectionView 瀑布流 添加表头视图的坑
UICollectionView 瀑布流 添加表头视图的坑 首先是,需求加了个头视图在顶部,在collectionView中的头视图跟TableView的不一样,TableView的表头只要设置tab ...
- Swift - iOS中各种视图控制器(View Controller)的介绍
在iOS中,不同的视图控制器负责不同的功能,采用不同的风格向用户呈现信息.下面对各个视图控制器做个总结: 1,标准视图控制器 - View Controller 这个控制器只是用来呈现内容.通常会用来 ...
- IOS中调用系统的电话、短信、邮件、浏览功能
iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...
随机推荐
- python安装matplotlib:python -m pip install matplotlib报错
matplotlib是python中强大的画图模块. 首先确保已经安装python,然后用pip来安装matplotlib模块. 进入到cmd窗口下,建议执行python -m pip install ...
- MySQL的存储(二、创建表并插入)
创建表 首先创建一个 spiders的数据库 cursor.execute("create database spiders default character set utf8" ...
- Mac 配置 PlantUML
PlantUML简介 UML: Unified Modeling Language 统一建模语言,是非专利的第三代建模和规约语言.UML是一种开放的方法,用于说明.可视化.构建和编写一个正在开发的.面 ...
- ARTS-S golang panic返回默认值
package main import "fmt" func fn_test_panic() (a int) { a = 2 panic("This is panic&q ...
- 网络基础TCP/IP
TCP/IP协议族各层的作用如下 应用层 决定了向用户提供应用服务时通信的活动: 各类通用的应用服务.FTP(File Transfer Protocol,文件传输协议).DNS(Domain Nam ...
- 【JS】369- 20个常用的JavaScript字符串方法
点击上方"前端自习课"关注,学习起来~ 作者:前端小智 https://segmentfault.com/a/1190000020204425 本文主要介绍一些最常用的JS字符串函 ...
- redis(5)--redis集群之哨兵机制
哨兵机制 在前面讲的master/slave模式,在一个典型的一主多从的系统中,slave在整个体系中起到了数据冗余备份和读写分离的作用.当master遇到异常终端后,需要从slave中选举一个新的m ...
- Linux查看文本的第20~30行
一.模拟环境 [root@WT ~]# seq >/data/test.txt [root@WT ~]# xargs -n </data/test.txt 二.实现命令 方法一(head+ ...
- tabhost改变标签颜色
package uiframe.zyx.uiframe.com.uiframe.fragments;import android.os.Bundle;import android.support.an ...
- hdu 6301 Distinct Values (贪心)
Distinct Values Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...