我的 iPhoneApp 中有一个普通的 UITableView。我想更改标题文本的字体大小。我知道这是不可能的,我需要使用自己的标签创建自定义标题。
我只是想知道是否有人知道我如何重现类似于标准的标题(使用相同的背景图像等......)?我在任何地方都找不到背景图片..
最好的问候,乔纳森
我的 iPhoneApp 中有一个普通的 UITableView。我想更改标题文本的字体大小。我知道这是不可能的,我需要使用自己的标签创建自定义标题。
我只是想知道是否有人知道我如何重现类似于标准的标题(使用相同的背景图像等......)?我在任何地方都找不到背景图片..
最好的问候,乔纳森
您正在寻找[UIColor groupTableViewBackgroundColor]
:
[view setBackgroundColor:[UIColor groupTableViewBackgroundColor]];
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 :)