您好,我正在学习为 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/