我的UIViewController视图中添加了一个UINavigationBar.我想更改字体属性.请注意,我想更改UINavigationBar而不是控制器.在我使用UINavigationController的应用程序中,我使用self.navigationItem.titleView = label;来显示自定义标签.

如何在我的UINavigationBar中实现自定义标题?

另外,我用它来设置UINavigationBar的标题文本self.navBar.topItem.title = @"Information";.

推荐答案

从iOS 5开始,我们必须使用titleTextAttribute字典(UInavigation controller类参考中的预定义字典)设置导航栏的标题文本 colored颜色 和字体.

[[UINavigationBar appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
        [UIColor blackColor], NSForegroundColorAttributeName, 
           [UIFont fontWithName:@"ArialMT" size:16.0], NSFontAttributeName,nil]];

下面的教程是定制UInavigation bar、UIsegmented control、uitabar等ui元素的最佳教程.这可能对你有帮助

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

Objective-c相关问答推荐

iPhone 可达性判断

将谷歌 map 添加为子视图会使 iOS 应用程序因 exc_bad 崩溃

在从 UIViewController 调用的非保留完成中引用 self 时,weakSelf/strongSelf 舞蹈真的有必要吗?

如何获取目标名称?

在 Objective C 中动态调用类方法

为什么在目标 c 的静态上下文中允许 self

NSTimeInterval 格式

ios 13 - 带有 UISearchBar _searchField 的自定义 SearchBar 不起作用

如果用户禁用了应用程序的推送,是否可以进行静默远程通知?

UIScreen MainScreen Bounds 返回错误的大小

Objective-C:如何从子类访问父属性?

设置数据后调整 UICollectionView 单元格的大小

iOS6:supportedInterfaceOrientations 不起作用(被调用但界面仍然旋转)

Objective-C:块 vs. Select 器 vs. 协议

WKWebView 判断 JavaScript 返回值

如何在 NSSet 或 NSArray 中搜索具有特定属性的特定值的对象?

将 UIColor 保存到 NSUserDefaults 并从中加载

在 UICollectionView 上重置滚动

cellForRowAtIndexPath 是如何工作的?

为什么 Select Emacs/Vim/Textmate? Xcode 还不够好吗?