UITableView - change section header color

前端 未结 30 2883
不思量自难忘°
不思量自难忘° 2020-11-27 08:50

How can I change color of a section header in UITableView?

EDIT: The answer provided by DJ-S should be considered for iOS 6 and above. The accepted

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 09:32

    Just change the color of layer of the header view

    - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
    {
      UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0,    tableView.bounds.size.width, 30)] autorelease];
     headerView.layer.backgroundColor = [UIColor clearColor].CGColor
    }
    
    

提交回复
热议问题