gpt4 book ai didi

iphone - UITableView 字体

转载 作者:行者123 更新时间:2023-12-03 20:47:24 27 4
gpt4 key购买 nike

我正在尝试更改 TableView 标题上的字体颜色,其中显示“加利福尼亚/纽约”。我该怎么做?

在黑色背景上,文本需要是白色的,但无法弄清楚这一点。

谢谢

alt text

最佳答案

如果您尝试更改标题颜色,可以使用以下命令:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 44.0)];

// create the button object
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
//THE COLOR YOU WANT:
headerLabel.textColor = [UIColor blackColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
//THE FONT YOU WANT:
headerLabel.font = [UIFont boldSystemFontOfSize:20];
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 44.0);

// If you want to align the header text as centered
// headerLabel.frame = CGRectMake(150.0, 0.0, 300.0, 44.0);
//THE TEXT YOU WANT:
headerLabel.text = <Put here whatever you want to display> // i.e. array element
[customView addSubview:headerLabel];

return customView;
}

关于iphone - UITableView 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4579420/

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