这是代码,这将显示默认大小,我想更改标题becoz的字体大小这个标题太大n没有显示整个只有“库克大印度......”正在显示...请允许我帮忙
- (void)viewDidLoad {
self.title = @"Cook Great Indian Recipes";
}
答案 0 :(得分:11)
尝试为标题标签设置自定义标签:
self.title = @"Cook Great Indian Recipes";
CGRect frame = CGRectMake(0, 0, [self.title sizeWithFont:[UIFont boldSystemFontOfSize:20.0]].width, 44);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:17.0];
label.textAlignment = UITextAlignmentCenter;
self.navigationItem.titleView = label;
label.text = self.title;
[label release];
答案 1 :(得分:3)
您无法更改title
的字体。而是使用您自己的自定义创建UILabel
,并将其指定为 navigationItem的 titleView
。
UILabel *titleLbl = [[UILabel alloc] init];
label.frame = CGRectMake(...
label.font = [UIFont ...
// And the other things
self.navigationItem.titleView = titleLbl;
[titleLbl release];