一般的我们都是通过自定义视图来设置导航条的title颜色和字体的
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
titleLabel.text = @"详情";
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = NSTextAlignmentCenter;
self.navigationItem.titleView = titleLabel;
但是iOS6之后有了新的方法可以直解设置title的字体和颜色
[self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont systemFontOfSize:20], NSFontAttributeName, nil]];
iOS6 导航条title字体和颜色-不使用自定义视图
最新推荐文章于 2014-10-27 20:17:03 发布