xcode 在 iPhone 视图中更改标题的颜色和背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5547802/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change the color & background of title in iPhone view
提问by Ashish K Agarwal
i have a tab bar controller as a root controller. In its first tab I have a navigation controller containing an ungrouped table view
我有一个标签栏控制器作为根控制器。在它的第一个选项卡中,我有一个包含未分组表视图的导航控制器
Screenshot is at - http://sankalplabs.files.wordpress.com/2011/04/screen-shot-2011-04-05-at-11-17-10-am.png
屏幕截图位于 - http://sankalplas.files.wordpress.com/2011/04/screen-shot-2011-04-05-at-11-17-10-am.png
(Since I am new to this forum, its not allowing me to upload the image)
(因为我是这个论坛的新手,所以不允许我上传图片)
Now i want to change the color & background of the title "Smart Analytics". I tried using a label & placing it on the title. But it has not worked. What is the way to do this ?
现在我想更改标题“智能分析”的颜色和背景。我尝试使用标签并将其放在标题上。但它没有奏效。有什么方法可以做到这一点?
回答by reflog
self.navigationController.tintColor = [UIColor greenColor];
回答by Jhaliya
Try with titleView
property of UINavigationItem
尝试使用titleView
属性UINavigationItem
@property(nonatomic, retain) UIView *titleView
Can be accessed like below In UIViewController
inherited class.
可以像下面那样访问在UIViewController
继承的类中。
self.navigationItem.titleView = myOwnLabel;
Related SO post
相关SO帖子
Changing the Title View of a UINavigationController UIViewController in Interface Builder
在 Interface Builder 中更改 UINavigationController UIViewController 的标题视图
回答by Dipak Narigara
use this
self.navigationController.navigationBar.tintColor = [UIColor greenColor];