方法一:(自定义导航栏标题视图的方法,一般人也会采用这样的方式;更有甚者会自定义导航栏。。。只是修改一下标题字体大小和颜色,有点夸张了。。。)

就是在导航向上添加一个titleView,可以使用一个label,label的背景颜色默认透明,字体什么的设置就很简单了。

//自定义标题视图

UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];

titleLabel.backgroundColor = [UIColor grayColor];

titleLabel.font = [UIFont boldSystemFontOfSize:20];

titleLabel.textColor = [UIColor greenColor];

titleLabel.textAlignment = NSTextAlignmentCenter;

titleLabel.text = @"新闻";

self.navigationItem.titleView = titleLabel;

​

方法二:(在默认显示的标题中直接修改文件的大小和颜色也是可以的)

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor redColor]}];

方式二相对于方式一而言更加简单方便。

​

方法三:统一导航条样式(一般写在AppDelegate中),一劳永逸

UIFont *font = [UIFontsystemFontOfSize:17.f];

NSDictionary *textAttributes = @{

    NSFontAttributeName : font,

    NSForegroundColorAttributeName : [UIColorwhiteColor]

};

[[UINavigationBarappearance] setTitleTextAttributes:textAttributes];

[[UINavigationBarappearance] setTintColor:[UIColorwhiteColor]];

[[UINavigationBarappearance] setBarTintColor:[UIColorcolorWithHexString:@"0195ff"alpha:1.0f]];

results matching ""

    No results matching ""