[iOS UItableView 自定义Section] 自定义Section 修改title样式

来源:互联网 发布:有网络但是不能玩游戏 编辑:程序博客网 时间:2024/05/10 09:56

自定义Section

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{    UIView *v = [UIView new];    v = [[UIView alloc] initWithFrame:CGRectMake(0, 0, NEWWIDTH, 30)];    [v setBackgroundColor:[Common hexStringToColor:@"e4e4e4"]];    UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(15,0,v.width,v.height)];    [labelTitle setBackgroundColor:[Common hexStringToColor:@"e4e4e4"]];    labelTitle.textAlignment = NSTextAlignmentLeft;    labelTitle.font = [UIFont systemFontOfSize:12];    labelTitle.textColor = [UIColor darkGrayColor];    if (section == 0) {        labelTitle.text = @"乘车人";    }else if (section == 1){         labelTitle.text = @"订单信息";    }    [v addSubview:labelTitle];    return v;}

直接返回Title的话

- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{    return @"lalalala"}
0 0
原创粉丝点击