我有UITableView
它从 plist 中填充日期,甚至部分的标题是从 plist 中填充的。UITableView
它给了我默认的blue
部分颜色和White
文本颜色。像这样......
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSString *key = nil;
if ([tableView isEqual:self.searchDisplayController.searchResultsTableView])
{
key = [self.searchResults objectAtIndex:section];
}
else{
key = [self.mySections objectAtIndex:section];
}
// NSString *key = [self.mySections objectAtIndex:section];
return [NSString stringWithFormat:@"%@", key];
}
. 现在我需要更改此默认文本颜色和部分的颜色,为此我正在实现下面显示的代码。但它给了我自己的UIView
.
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(0,200,300,244)];
tempView.backgroundColor=[UIColor clearColor];
UILabel *tempLabel=[[UILabel alloc]initWithFrame:CGRectMake(15,0,300,44)];
tempLabel.backgroundColor=[UIColor clearColor];
tempLabel.shadowColor = [UIColor blackColor];
tempLabel.shadowOffset = CGSizeMake(0,2);
tempLabel.textColor = [UIColor redColor]; //here you can change the text color of header.
tempLabel.font = [UIFont fontWithName:@"Helvetica" size:fontSizeForHeaders];
tempLabel.font = [UIFont boldSystemFontOfSize:fontSizeForHeaders];
tempLabel.text=@"Header Text";
[tempView addSubview:tempLabel];
[tempLabel release];
return tempView;
}