Riv*_*van 9 iphone cocoa-touch uinavigationcontroller ios
我UINavigationBar在我的应用程序中使用了UITabBar.在第一个选项卡上,导航栏标题正确地作为带有默认背景颜色的白色标题,但在第二个选项卡上它不能以相同的方式工作.我没有使用任何代码来更改标题颜色或导航栏tintColor.
第一种观点:http:
//img407.imageshack.us/img407/7192/4go.png
第二种观点:http: //img824.imageshack.us/img824/4493/idtk.png
为什么第二个视图的UINavigationBar标题是用这种黑色绘制的?
iPa*_*tel 26
通常,您无法更改UINavigationBar标题的默认颜色.如果你想改变UINavigationBar Title的颜色,你需要自定义UINavigationBar.所以为你的第二个ViewController添加代码以获得更多理解.
编辑:
搜索后,我发现,您可以更改标题颜色UINavigationBar由
self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor];
此代码适用于iOS5及更高版本.
gir*_*_vr 11
以上大多数建议现已弃用,iOS 7使用 -
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys: 
                               [UIColor whiteColor],NSForegroundColorAttributeName, 
                               [UIColor whiteColor],NSBackgroundColorAttributeName,nil];
self.navigationController.navigationBar.titleTextAttributes = textAttributes;
self.title = @"Title of the Page";
另外,检查NSAttributedString.h以获取可以设置的各种文本属性.
在AppDelegate中试试这个:
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
小智 7
这将允许您更改颜色
NSDictionary *navbarTitleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [UIColor whiteColor],UITextAttributeTextColor, 
                                        [UIColor blackColor],      UITextAttributeTextShadowColor, 
                                        [NSValue valueWithUIOffset:UIOffsetMake(-1, 0)], UITextAttributeTextShadowOffset, nil];
[[UINavigationBar appearance] setTitleTextAttributes:navbarTitleTextAttributes];
| 归档时间: | 
 | 
| 查看次数: | 15017 次 | 
| 最近记录: |