更改UINavigationBar字体属性? [英] Change UINavigationBar font properties?
问题描述
我有一个UINavigationBar添加到我的UIViewController视图。我想更改字体属性。注意,我想更改一个UINavigationBar而不是控制器。在我使用UINavigationController的应用程序中,我使用 self.navigationItem.titleView = label;
显示自定义标签。
I have an UINavigationBar added to my UIViewController view. I want to change the fonts properties. Note that I want to change a UINavigationBar not controller. In my app where I use UINavigationController I use self.navigationItem.titleView = label;
to display the custom label.
如何在UINavigationBar中完成自定义标题?
How can I accomplish to have a custom title in my UINavigationBar?
我用这个来设置标题文本 self.navBar.topItem.title = @Information;
的UINavigationBar。
P.S I use this to set the title text self.navBar.topItem.title = @"Information";
of my UINavigationBar.
推荐答案
从iOS 5开始,我们必须使用titleTextAttribute字典来设置导航栏的标题文本颜色和字体类引用)。
From iOS 5 onwards we have to set title text color and font of navigation bar using titleTextAttribute Dictionary(predefined dictionary in UInavigation controller class reference).
[[UINavigationBar appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor blackColor], NSForegroundColorAttributeName,
[UIFont fontWithName:@"ArialMT" size:16.0], NSFontAttributeName,nil]];
下面的教程是UIElements定制的最佳教程,如UInavigation bar,UIsegmented control,UITabBar。这可能对您有帮助
The below tutorial is the best tutorial for customization of UIElements like UInavigation bar, UIsegmented control, UITabBar. This may be helpful to you
http://www.raywenderlich.com/4344/user-interface-customization-in-ios-5
这篇关于更改UINavigationBar字体属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!