iOS经验总结

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

2018-04-03  本文已影响0人  我一不小心就

方案1:

[self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19.0f],
       NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"]}];

方案2:在导航上添加一个titleView,可以使用一个UILable,再设置label的背景颜色透明,字体,即:自定义一个自定义标题视图

UILabel *titleLabel = [[UILabel 
alloc] initWithFrame:CGRectMake(0, 
0, 200, 44)];
// 设置titleLabel的各种属性
xxxxxx
xxxxx
xxx
// 最后
self.navigationItem.titleView = titleLabel;
上一篇 下一篇

猜你喜欢

热点阅读