繁体   English   中英

如何在iphone中更改标题的字体大小?

[英]How to change font size of title in iphone?

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

- (void)viewDidLoad {

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

尝试为标题标签设置自定义标签:

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

您无法更改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];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM