您的位置:首页 > 移动开发 > IOS开发

iOS tableview viewForHeaderInSection 自定义

2014-08-30 11:08 411 查看
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc] init];
//设置 title 区域
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, tableView.contentSize.width, 20)];
//设置 title 文字内容
titleLabel.text = @"标题内容";
//设置 title 颜色
titleLabel.textColor =  [UIColor colorWithRed:221/255.0 green:61/255.0 blue:47/255.0 alpha:1];

[view addSubview:titleLabel];
return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
//设置 title 区域高度
return 40.f;
}


效果图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐