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

标签 ios objective-c

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

相关文章:

ios - React Native 应用程序在 Debug模式下工作,但在 iOS 上不工作 Release模式

ios - UITableViewController 中的状态栏

ios - ionic 2 iOS cors

ios - 当作为 git 子模块包含时,我是否必须 fork 第 3 方库以便进行小的更改?

ios - 如何以编程方式检测 iPhone XS 或 iPhone X?

ios - 上传视频到服务器

ios - Swift - segue 以编程方式第一次需要两秒钟来显示 View Controller

ios - UITableView 单元格的编辑模式转换

iphone - 在ios中将html转换为图像

ios - 添加为 subview 后调整 UITableView (带 Controller )的大小?