更改UITable部分标题颜色

我想改变UITableView节头的颜色。

使用下面的代码为您的答案

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *tempView=[[[UIView alloc]initWithFrame:CGRectMake(0,0,300,44)]autorelease]; tempView.backgroundColor=[UIColor redColor]; UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(0,0,300,44)]; tempLabel.backgroundColor=[UIColor clearColor]; tempLabel.text=@"MY HEADER"; [tempView addSubview: tempLabel]; [tempLabel release]; return tempView; } 

这会给你一个redColor标题。 根据您的要求更改颜色…

编辑(根据苛刻):

由于标题中的视图将与第一个单元格重叠,因此请增加标题的高度

 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 50; } 

快乐编码……..

使用- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section这个方法是UITableViewDelegate的一部分用标签返回视图。 您现在可以configuration标签颜色。