2011-08-18 238 views
2

这是代码,这将显示默认大小,我想改变标题的字体大小becoz这个标题太大n没有显示整个“库克大印度...”显示... pl让我帮忙如何更改iPhone中的标题字体大小?

- (void)viewDidLoad { 

    self.title = @"Cook Great Indian Recipes"; 
} 
+0

从厦门国际银行的属性检查器,可以eaisly实现它。 – rptwsthi

回答

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]; 
+0

thnx为你的回应bt这是行不通的... –

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]; 
+0

thnx伙计这是工作perfactly.1.1c再次thnx给予例如.. –

相关问题