Swift - 给表格TableView添加页眉和页脚
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import UIKitclass ViewController: UIViewController,UITableViewDelegate, UITableViewDataSource,UIGestureRecognizerDelegate { var tableView:UITableView? var ctrlnames:[String] = ["UILabel 标签","UIButton 按钮","UIDatePiker 日期选择器"] override func viewDidLoad() { super.viewDidLoad() //创建表视图 self.tableView = UITableView(frame: UIScreen.mainScreen().applicationFrame, style:UITableViewStyle.Plain) self.tableView!.delegate = self self.tableView!.dataSource = self //创建一个重用的单元格 self.tableView!.registerClass(UITableViewCell.self, forCellReuseIdentifier: "SwiftCell") self.view.addSubview(self.tableView!) //给TableView添加表头页眉 var headerView:UIView = UIView(frame: CGRectMake(0,0,tableView!.frame.size.width,60)) var headerlabel:UILabel = UILabel(frame: headerView.bounds) headerlabel.textColor = UIColor.whiteColor() headerlabel.backgroundColor = UIColor.clearColor() headerlabel.font = UIFont.systemFontOfSize(16) headerlabel.text = "TableView 页眉" headerView.addSubview(headerlabel) headerView.backgroundColor = UIColor.blackColor() tableView?.tableHeaderView = headerView //给TableView添加表头页尾 var footerView:UIView = UIView(frame: CGRectMake(0,0,tableView!.frame.size.width,60)) var footerlabel:UILabel = UILabel(frame: footerView.bounds) footerlabel.textColor = UIColor.whiteColor() footerlabel.backgroundColor = UIColor.clearColor() footerlabel.font = UIFont.systemFontOfSize(16) footerlabel.text = "TableView 页眉" footerView.addSubview(footerlabel) footerView.backgroundColor = UIColor.blackColor() tableView?.tableFooterView = footerView } //在本例中,只有一个分区 func numberOfSectionsInTableView(tableView: UITableView!) -> Int { return 1; } //返回表格行数(也就是返回控件数) func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.ctrlnames.count } //创建各单元显示内容(创建参数indexPath指定的单元) func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //为了提供表格显示性能,已创建完成的单元需重复使用 let identify:String = "SwiftCell" //同一形式的单元格重复使用,在声明时已注册 let cell = tableView.dequeueReusableCellWithIdentifier(identify, forIndexPath: indexPath) as UITableViewCell cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator cell.textLabel?.text = self.ctrlnames[indexPath.row] return cell }} |
Swift - 给表格TableView添加页眉和页脚的更多相关文章
- iOS开发——UI_swift篇&TableView实现页眉和页脚
TableView实现页眉和页脚 在UItableView中header和footer是很常见的,而且他能让你实现很复杂的功能,我们见过最多的就是下拉刷新和上啦加载更多,当然你还可以在上面添加一个 ...
- openxml(二) 添加页眉,页脚
openxml 中 word 文档的结构是如下图: 其中,页眉是 header,属于headerpart 部件,页脚是footer,属于footerpart 部件,图上还有其他的东西,之后会一一介绍. ...
- C# 操作Word 文档——添加Word页眉、页脚和页码
在Word文档中,我们可以通过添加页眉.页脚的方式来丰富文档内容.添加页眉.页脚时,可以添加时间.日期.文档标题,文档引用信息.页码.内容解释.图片/LOGO等多种图文信息.同时也可根据需要调整文字或 ...
- C# 添加Word页眉、页脚和页码
在Word文档中,我们可以通过添加页眉.页脚的方式来丰富文档内容.添加页眉.页脚时,可以添加时间.日期.文档标题,文档引用信息.页码.内容解释.图片/LOGO等多种图文信息.同时也可根据需要调整文字或 ...
- C# 给现有PDF文档添加页眉、页脚
概述 页眉页脚是一篇完整.精致的文档的重要组成部分.在页眉页脚处,可以呈现的内容很多,如公司名称.页码.工作表名.日期.图片,如LOGO.标记等.在之前的文章中介绍了如何通过新建一页空白PDF页来添加 ...
- CAD在网页中打印的图纸里面添加页眉及页脚
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- NCreport报表控件教程:设计页眉和页脚
一.设计页眉 一般来说页眉部分一般是用于包含标题的内容, 首先我们会添加列标签到页眉部分,标签都是简单的文本,标签项一般是用于在报表上显示一些描述信息,标签都是静态项,所以它们的值不会有变化. 添加标 ...
- iText5报表_页眉与页脚
1.概述 iText5中并没有之前版本HeaderFooter对象设置页眉和页脚,可以利用PdfPageEventHelper来完成页眉页脚的设置工作.PdfPageEventHelper ...
- word页眉与页脚详解
1.如何隔离封面等不需要插入页码的页面: 首先插入分节符下一页(一定是分节符),再在下一页(即要开始插入页码的页面)选择视图-->页眉和页脚-->设置为取消链接到前一页.设置页码格式为起始 ...
随机推荐
- ThinkPHP - 每个操作都检测用户是否登录
TP提供了一个自动执行的函数_initialize(), 你创建一个公共控制器CommonAction.class.php文件. 定义了此方法,不能存在构造方法__construct() <?p ...
- 【Nginx】启动报错-端口被占用
将下载的windows版nginx的压缩包nginx-1.4.2.zip解压到F:\server\nginx-1.4.2里面. dos命令键入: F: cd F:\server\nginx-1.4.2 ...
- akka actor中的基本概念(学习小结)
注:本文章是看blog后的一个阶段小结,只作为个人笔记, 原文链接:http://www.iteblog.com/archives/1154 官网地址贴上:http://doc.akka.io/doc ...
- CSS Filter
支持的效果有: blur(模糊) grayscale(灰度) drop-shadow(阴影) sepia(褐色滤镜) brightness(亮度) contrast(对比) hue-rotate(色相 ...
- 1.unix网络编程基础知识
接触网络编程一年多了,最近在系统的学习vnp两本书,对基础知识做一些总结,希望理解的更透彻清晰,希望能有更多的沉淀. 1.套接口地址 针对IPv4和IPv6地址族,分别定义了两种类型的套接口地址:so ...
- 浅析Linux的软中断的实现
參考: http://bbs.chinaunix.net/thread-2333484-1-1.html http://liu1227787871.blog.163.com/blog/static/2 ...
- ListView中加入Button后,Button的点击事件和ListView的点击事件冲突
1.在ItemView配置的xml文件里的根节点加入属性android:descendantFocusability="blocksDescendants" 2.在要加入事件的控件 ...
- RequiredFieldValidator控件--必填验证控件
RequiredFieldValidator控件: ·RequiredFieldValidator控件也被称之为必填验证控件,顾名思义,也就是与RequiredFieldValidator控件关联的控 ...
- Java--格式化输出
Java的格式化输出等同于String.Format,与C有很大的相似,比如 System.out.printf("%8.2f", x); 在printf中,可以使用多个参数,例如 ...
- django目录下的各文件
本文部分转载. 使用Python setup.py install命令从源代码安装完Django后,这些都会被拷贝到Python安装目录下的Lib/site-packages/django子目录中.之 ...