1.分区
在界面文件中可以设置tableview是否为分区显示,可以设置每个cell之间的分割线的样式,颜色。
设置分组的标题的样式:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView * headerView = [[UIView alloc]initWithFrame:CGRectMake(0,0, 250, 25)];
[headerView setBackgroundColor:[UIColor grayColor]];
UILabel * title;
if (section == 0) {
UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 350, 20)];
title = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, 100, 15)];
view.backgroundColor = [UIColor blackColor];
[headerView addSubview:title];
title.font = [UIFont boldSystemFontOfSize:16.0f];
title.textColor = [UIColor whiteColor];
title.text = [_dataKeys objectAtIndex:section];
[headerView addSubview:view];
}else {
title = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 15)];
title.font = [UIFont boldSystemFontOfSize:16.0f];
title.textColor = [UIColor whiteColor];
title.text = [_dataKeys objectAtIndex:section];
[headerView addSubview:title];
}
return headerView;
}
2.tableview
可以设置背景颜色,可以设置字体颜色。