gpt4 book ai didi

iphone - 更改 UITable 部分标题颜色

转载 作者:行者123 更新时间:2023-12-01 17:35:23 28 4
gpt4 key购买 nike

我想更改 UITableView 部分标题的颜色。

最佳答案

使用以下代码作为您的答案

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *tempView=[[[UIView alloc]initWithFrame:CGRectMake(0,0,300,44)]autorelease];
tempView.backgroundColor=[UIColor redColor];
UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,300,44)];
tempLabel.backgroundColor=[UIColor clearColor];
tempLabel.text=@"MY HEADER";
[tempView addSubview: tempLabel];
[tempLabel release];
return tempView;
}

这会给你一个 redColor 标题。根据您的要求更改颜色...

已编辑(根据 Harsh):

由于标题中的 View 将与您的第一个单元格重叠,因此增加标题的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}

快乐的编码......

关于iphone - 更改 UITable 部分标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3715390/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com