iPhone UINavigationBar使用[UINavigationBar外观]更改所有控制器的字体样式 [英] iPhone UINavigationBar change font style for all controllers with [UINavigationBar appearance]

查看:147
本文介绍了iPhone UINavigationBar使用[UINavigationBar外观]更改所有控制器的字体样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以单独更改导航栏的字体,如下所示:更改导航栏的字体

I'm aware that I can individually change the font of a navigation bar as outlined in this answer: Change the navigation bar's font

目前我正在使用更全球化的方法:

Currently I'm using a more global approach:

//in my app delegate:
    [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent];

有没有办法全局更改导航栏通过外观对象的字体?

Is there a way to globally change the font that the Navbar through the appearance object?

谢谢!

推荐答案

来自Ray Wenderlich:

From Ray Wenderlich:

http://www.raywenderlich。 com / 4344 / user-interface-customization-in-ios-5

// Customize the title text for *all* UINavigationBars
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
    [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0], 
    UITextAttributeTextColor, 
    [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8], 
    UITextAttributeTextShadowColor, 
    [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], 
    UITextAttributeTextShadowOffset, 
    [UIFont fontWithName:@"Arial-Bold" size:0.0], 
    UITextAttributeFont, 
    nil]];

这篇关于iPhone UINavigationBar使用[UINavigationBar外观]更改所有控制器的字体样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆