表格的Section HeaderTitle 标题样式自定义
来源:互联网 发布:淘宝后台修改器多少钱 编辑:程序博客网 时间:2024/05/16 04:39
当一个表格分有多个段(拥有多个section)并且每段内容不同时,我们就会在每段的开头进行文字说明。就是我们的SectionHeader Tltle。
对于Header进行自定义时,我们往往会添加图片或者文字进行美化,接下来要说的就是这一过程。
OK,还是先看看实现步骤:
调用代理方法==》自定义美化效果或者文字效果==》自定义好后,返回这个效果。
OK,下面上过程:
首先是调用代理方法,表格有一个关于SectionHeader的函数:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {};
调出来,然后在函数里进行效果自定义:
//###############- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { //创建一个用于返回效果的UIView,用来承接文字或图片 UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)] ; customView.backgroundColor=[UIColor orangeColor]; //自定义文字效果 UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero]; headerLabel.backgroundColor = [UIColor orangeColor]; //字体不透明 headerLabel.opaque =NO; headerLabel.textColor = [UIColor purpleColor]; // headerLabel.highlightedTextColor = [UIColor blackColor]; //字体效果 headerLabel.font = [UIFont boldSystemFontOfSize:18]; //设置label格式 headerLabel.frame = CGRectMake(10.0, 0.0, 320.0, 30.0); if (section == 0) { headerLabel.text = @"测试1"; }else if (section == 1){ headerLabel.text = @"测试2"; }else if (section == 2){ headerLabel.text = @"测试3"; }else if (section == 3){ headerLabel.text = @"测试4"; } //将自定义的内容添加到UIView上 [customView addSubview:headerLabel]; //返回自定义好的效果 return customView;}//别忘了设置高度- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 30.0;}//###############
一个简单的效果就出来啦~
当然,更多的效果,大家自己设计吧~
0 0
- 表格的Section HeaderTitle 标题样式自定义
- 自定义GridView的表格样式
- 自定义UITableView的Section的title的样式
- 自定义UITableView的Section的title的样式
- android 自定义标题样式
- Android标题样式自定义
- 自己实现的数据表格控件(dataTable),支持自定义样式和标题数据、ajax等各种自定义设置以及分页自定义
- [iOS UItableView 自定义Section] 自定义Section 修改title样式
- 自定义ActionBar的高度、标题与菜单中的文字样式
- 带标题的表格
- 收集的表格样式
- 表格的css样式
- 表格导出的样式
- 修改UITableView section header title的样式
- 自定义Section:修改UITableView的Section的背景和字体
- 自定义Section:修改UITableView的Section的背景和字体
- 应用样式后的标题
- 更改ACTIVITY的标题样式
- Semantic Issue: Implicit declaration of function 'SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO' is invali
- Visual Studio 2010 SP1 that matches the language version of Silverlight 5 Tools must be installed be
- Linux常用命令英文全称与中文解释Linux系统
- [数据结构]各种排序算法比较
- 用map统计字符串中字符出现的次数
- 表格的Section HeaderTitle 标题样式自定义
- JQuery的ajax()方法
- python 多进程实例
- vxworks辅助时钟
- Jackson的Json转换
- Sysgen和Build and Sysgen
- 第九周项目四—乘法口诀表
- import Android项目出现Project has no project.properties file! Edit the project properties to set one.
- 第9周项目6(5)-解奥数题