Changing the color of UITableView section headers

前端 未结 6 1284
抹茶落季
抹茶落季 2020-12-31 01:47

OK, I know that this has been asked previously, so please forgive me for asking again. It just seems like there has got to be an easier way to do this.

Is there a \

6条回答
  •  抹茶落季
    2020-12-31 02:23

    If you change the appearance, like in the other answers, it is application wide. If you want to change just for a specific tableview, implement:

    -(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
      UITableViewHeaderFooterView * headerview = (UITableViewHeaderFooterView *)view;
      headerview.contentView.backgroundColor = [UIColor greenColor];
      headerview.textLabel.textColor = [UIColor whiteColor];
    }
    

提交回复
热议问题