ios修改导航条title的颜色

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

你可能感兴趣的:(ios修改导航条title的颜色)