只需要在下面方法里自定义 View 即可:
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [[self.list objectAtIndex:section] valueForKey:@"title"];
// Create header view and add label as a subview
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10.0,
0.0,
320.0,
100.0)];
view.backgroundColor = [UIColor lightGrayColor];
// Create label with section title
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(5.0,
12.0,
284.0,
24.0);
label.textColor = [UIColor blackColor];
label.font = [UIFont systemFontOfSize:16.0];
label.text = sectionTitle;
label.backgroundColor = [UIColor clearColor];
[view addSubview:label];
return view;
}
iOS UITableView 修改 分区表头的样式和颜色
最新推荐文章于 2024-01-11 22:19:27 发布