self.title = @"title";
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSFontAttributeName:[UIFont systemFontOfSize:19],
NSForegroundColorAttributeName:[UIColor redColor]}];
1、第二种方法
//自定义标题视图
UILabel *navTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
navTitleLabel.backgroundColor = [UIColor blackColor];
navTitleLabel.font = [UIFont boldSystemFontOfSize:25];
navTitleLabel.textColor = [UIColor greenColor];
navTitleLabel.textAlignment = NSTextAlignmentCenter;
navTitleLabel.text = @"title";
self.navigationItem.titleView = navTitleLabel;
转载请注明出处:http://blog.csdn.net/sevenquan
本文介绍两种在iOS应用中自定义导航栏标题的方法:一是通过设置标题文字属性实现颜色和字体大小的变化;二是创建自定义的UILabel作为标题视图,并设定其样式。

5106

被折叠的 条评论
为什么被折叠?



