gpt4 book ai didi

ios - 我想更改 Objective C 标题中的颜色。为 ios 创建调整

转载 作者:行者123 更新时间:2023-11-28 23:37:15 24 4
gpt4 key购买 nike

您好,我正在学习为 iOS 开发调整。我下载了一个开源调整,我首先想改变颜色。我把它们都改了,除了一个我不知道怎么做。我想将标题的标题设为白色,居中,文本更大

- (NSString *)tableView:(UITableView *)table titleForHeaderInSection:(NSInteger)section {
switch (section) {
case 0:
return @"Border Size";
case 1:
return @"Border Color";
case 2:
return @"Badge Tint Alpha";
default:
return nil;
}
}

最佳答案

titleForHeaderInSection只能返回一个字符串,需要自己实现

 NSArray*arr ;
NSArray*colors;

viewDidLoad

arr = [@"Border Size",@"Border Color",@"Badge Tint Alpha"];
colors = [[UIColor redColor],[UIColor blueColor],[UIColor greenColor]];

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { 
UILabel*lbl = [UILabel new];
lbl.text = arr[section];
lbl.backgroundColor = colors[section];
return lbl;
}

关于ios - 我想更改 Objective C 标题中的颜色。为 ios 创建调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54584745/

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