//Section的标题栏高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == )
return ;
else
return 30.0f;
} -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect headerFrame = CGRectMake(, , , );
CGFloat y = ;
if (section == ) {
headerFrame = CGRectMake(, , , );
y = ;
}
UIView *headerView = [[UIView alloc] initWithFrame:headerFrame];
UILabel *dateLabel=[[UILabel alloc] initWithFrame:CGRectMake(, y, , )];//日期标签
dateLabel.font=[UIFont boldSystemFontOfSize:16.0f];
dateLabel.textColor = [UIColor darkGrayColor];
dateLabel.backgroundColor=[UIColor clearColor];
UILabel *ageLabel=[[UILabel alloc] initWithFrame:CGRectMake(, y, , )];//年龄标签
ageLabel.font=[UIFont systemFontOfSize:14.0];
ageLabel.textAlignment=UITextAlignmentRight;
ageLabel.textColor = [UIColor darkGrayColor];
ageLabel.backgroundColor=[UIColor clearColor]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"MM dd,yyyy";
dateLabel.text = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:[NSDate date]]];
ageLabel.text = @"1岁 2天"; [headerView addSubview:dateLabel];
[headerView addSubview:ageLabel];
return headerView;
}

ios 自定义UITableView中分组的标题sectionview的更多相关文章

  1. iOS之UITableView中的cell因为重用机制导致新的cell的数据出现重复或者错乱

      UITableView中的cell可以有很多,一般会通过重用cell来达到节省内存的目的:通过为每个cell指定一个重用标识符(reuseIdentifier),即指定了单元格的种类,当cell滚 ...

  2. iOS解决UITableView中Cell重用带来的问题

    tableView的常规配置,当超出一屏的cell就会标上可重用的标识出列到可重用缓存池中,后面再根据可重用标识来到的可重的cell就会和前面显示同样内容. - (UITableViewCell *) ...

  3. ios 更改UITableview中Section的字体颜色

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UILabel *c ...

  4. iOS设置UITableView中Cell被默认选中后怎么触发didselect事件

    //默认选中某个cell [self.searchResultTV selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] a ...

  5. iOS 如何自定义UISearchBar 中textField的高度

    iOS 如何自定义UISearchBar 中textField的高度 只需设置下边的方法就可以 [_searchBar setSearchFieldBackgroundImage:[UIImage i ...

  6. (Ios 实战) 自定义UITableView

    自定义UITableView 分成两个部分 1 自定义UITableViewCell 继承UITableViewCell,同时提供接口,根据当前的数据,现实View 2  在UITableView中实 ...

  7. ios UITableView中Cell重用机制导致内容重复解决方法

    UITableView继承自UIScrollview,是苹果为我们封装好的一个基于scroll的控件.上面主要是一个个的 UITableViewCell,可以让UITableViewCell响应一些点 ...

  8. iOS学习之UITableView中Cell的操作

    接着iOS学习之Table View的简单使用 这篇,这里主要讲UITableView 中的Cell的操作,包括标记.移动.删除.插入. 为了简单快捷,直接从原来那篇的代码开始,代码下载地址:http ...

  9. iOS开发之UITableView中计时器的几种实现方式(NSTimer、DispatchSource、CADisplayLink)

    最近工作比较忙,但是还是出来更新博客了.今天博客中所涉及的内容并不复杂,都是一些平时常见的一些问题,通过这篇博客算是对UITableView中使用定时器的几种方式进行总结.本篇博客会给出在TableV ...

随机推荐

  1. jQuery knowledge

    I have used jquery for many years, but didn't list the problem I ever meeting, so here is a list of ...

  2. Atitit.web 视频播放器classid clsid 大总结quicktime,vlc 1. Classid的用处。用来指定播放器 1 2. <object> 标签用于包含对象,比如图像、音

    Atitit.web 视频播放器classid clsid 大总结quicktime,vlc 1. Classid的用处.用来指定播放器 1 2. <object> 标签用于包含对象,比如 ...

  3. 【Android】13.2 使用自定义的CursorAdapter访问SQLite数据库

    分类:C#.Android.VS2015: 创建日期:2016-02-26 一.简介 SQliteDemo1的例子演示了SimpleCursorAdapter的用法,本节我们将使用用途更广的自定义的游 ...

  4. mysql root 用户被删

    [root@M ~]# vi /etc/my.cnf [mysqld] skip-grant-tables [root@M ~]# service mysqld restart Shutting do ...

  5. struts2防止表单重复提交的解决方案

    一.造成重复提交主要的两个原因:    在平时的开发过程中,经常可以遇到表单重复提交的问题,如做一个注册页面,如果表单重复提交,那么一个用户就会注册多次,重复提交主要由于两种原因. 1. 一是,服务器 ...

  6. js基本知识2

    一.提示框 1. 弹出警示框 alert(); window.alert(); window 窗口 2. 控制台输出 console.log() 3. 文档打印 document 文档 documen ...

  7. jquery 怎么触发select的change事件

    可以使用jQuery的trigger() 方法来响应事件 定义和用法 trigger() 方法触发被选元素的指定事件类型. 语法 $(selector).trigger(event,[param1,p ...

  8. 替换元素节点replaceChild()

    替换元素节点replaceChild() replaceChild 实现子节点(对象)的替换.返回被替换对象的引用. 语法: node.replaceChild (newnode,oldnew ) 参 ...

  9. 读取数据库中timestamp类型去掉毫秒

    数据库中查询出来的时间是:2015-09-24 14:30:26.2,带有毫秒,需要去掉. 方法一: public static Timestamp getSystemTime() { Date dt ...

  10. The 14th UESTC Programming Contest Final B - Banana Watch 预处理、前缀和

    B - Banana Watch Time Limit: 1000/1000MS (Java/Others)     Memory Limit: 262144/262144KB (Java/Other ...