UITableView change header title color

后端 未结 6 643
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 10:18

I\'m styling the UITableView in InAppSettingsKit and want to change the color of the header title:

\"image

6条回答
  •  梦毁少年i
    2021-02-13 10:46

    Implement the tableView:viewForHeaderInSection: method in the tableViewController. That will allow you to supply your own view for the headers, which can include a UILabel with whatever formatting you want, e.g.

    -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        UILabel *customLabel = [[UILabel alloc] init];
        customLabel.text = [self tableView:tableView titleForHeaderInSection:section];
        return customLabel;
    }
    

    Remember to set the label frame to be tall enough to space out the sections. You may wish to embed the label inside a larger UIView and return that instead to simplify positioning (e.g. if you want increase the left-padding on the label).

提交回复
热议问题