iOS UITableView 修改 分区表头的样式和颜色

来源:互联网 发布:王者荣耀 女娲 知乎 编辑:程序博客网 时间:2024/06/05 10:55
只需要在下面方法里自定义 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;    }
0 0
原创粉丝点击