I am pretty sure that you cannot do this easily. I used one of my technical support requests on my dev account recently, asking for a change in the background and borders of the UITableView sections. The apple engineer told me this wasn’t easy, and even if you succeeded, you probably would have affected performance. He also pointed me to cocoawithlove and an article on editing uitableviews:
http://cocoawithlove.com/2009/08/adding-shadow-effects-to-uitableview.html
Indeed, creating your own headline is not so much effort. Below is the code that I pulled from one of my projects - it was commented out, so it may not work right away, but you can get the idea:
- (CAGradientLayer *) greyGradient { CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.startPoint = CGPointMake(0.5, 0.0); gradient.endPoint = CGPointMake(0.5, 1.0); UIColor *color1 = [UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:1.0]; UIColor *color2 = [UIColor colorWithRed:240.0f/255.0f green:240.0f/255.0f blue:240.0f/255.0f alpha:1.0]; [gradient setColors:[NSArray arrayWithObjects:(id)color1.CGColor, (id)color2.CGColor, nil]]; return gradient; } - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { CGFloat width = CGRectGetWidth(tableView.bounds); CGFloat height = [self tableView:tableView heightForHeaderInSection:section]; UIView *container = [[[UIView alloc] initWithFrame:CGRectMake(0,0,width,height)] autorelease]; container.layer.borderColor = [UIColor grayColor].CGColor; container.layer.borderWidth = 1.0f; CAGradientLayer *gradient = [self greyGradient]; gradient.frame = container.bounds; [container.layer addSublayer:gradient]; UILabel *headerLabel = [[[UILabel alloc] initWithFrame:CGRectMake(12,0,width,height)] autorelease]; headerLabel.backgroundColor = [UIColor clearColor]; headerLabel.font= [UIFont boldSystemFontOfSize:19.0f]; headerLabel.shadowOffset = CGSizeMake(1, 1); headerLabel.textColor = [UIColor whiteColor]; headerLabel.shadowColor = [UIColor darkGrayColor]; NSString *title = [self tableView:tableView titleForHeaderInSection:section]; headerLabel.text = title; return container; }
Make sure that
#import <QuartzCore/QuartzCore.h>
By the way ... this should not mimic the appearance of standard headers - this is just an example. But I'm sure with a bit of trial and error that you could change to mimic the standard ones and then change the colors slightly.
source share