您的位置:首页 > 移动开发 > IOS开发

iOS开发之设置导航栏标题的字体大小和颜色

2016-02-25 16:21 507 查看
方法一:自定义视图。

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];
titleLabel.backgroundColor = [UIColor grayColor];
titleLabel.font = [UIFont boldSystemFontOfSize:20];
titleLabel.textColor = [UIColor blueColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text = @"导航栏标题";
self.navigationItem.titleView = titleLabel;

方法二:在默认显示的标题中直接修改文字的大小和颜色。

self.navigationItem.title = @"导航栏标题";
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blueColor]}];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息