Jonathan
Jonathan

Reputation:

How can I reproduce the standard header for a plain UITableView

I have a plain UITableView in my iPhoneApp. I would like to change the font size of the header text. I understand that this is not possible and that I need to create my custom header with my own label.

I just wonder if anybody knows how I can reproduce a header similar to the standard one (using the same background image,etc...)? I can not find the background image anywhere..

Best regards, Jonathan

Upvotes: 1

Views: 1224

Answers (2)

Infrid
Infrid

Reputation: 346

It won't stretch REALLY high, because it will look bad, but this can get you out of dodge, create a stretchable image which uses a graphic of the original header (any iphone template png/psd has these readily extractable).

Then

UIImage *image = [UIImage imageNamed:@"tableHeader.png"];
UIImage *stretchImage = [image stretchableImageWithLeftCapWidth:5.0 topCapHeight:2.0];
UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:frame];
[backgroundImage setImage:stretchImage];

and either return that as part of the UIView you construct in your:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

method or (better still) add it as the background of whatever UIView subclass instance you're returning in that method.

Clearly, any width works, I've found I can get it up to 55pixels high without looking naff. Best answer is to replicate the gradient.. I'm too nooby for that though :)

Upvotes: 0

Can Berk Güder
Can Berk Güder

Reputation: 113400

You're looking for [UIColor groupTableViewBackgroundColor]:

[view setBackgroundColor:[UIColor groupTableViewBackgroundColor]];

Upvotes: 1

Related Questions