在viewForHeaderInSection
試試這個示例:
UIView* customView = [[UIView alloc] init];
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = YES;
headerLabel.textColor = [UIColor whiteColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.shadowColor = [UIColor colorWithRed:0.0f/255.0f green:0.0f/255.0f blue:0.0f/255.0f alpha:0.25f];
headerLabel.shadowOffset = CGSizeMake(0.0f, -1.0f);
headerLabel.font = [UIFont boldSystemFontOfSize:16];
headerLabel.frame = CGRectMake(10.0, 0.0, 232.0,40.0);
headerLabel.numberOfLines=2;
headerLabel.text=[self.keys objectAtIndex:section];
[customView setBackgroundColor:[UIColor colorWithRed:0.64f green:0.68f blue:0.72f alpha:1.0f]];
[customView addSubview:headerLabel];
return customView;