更改UINavigationBar外观backgroundimage时状态栏颜色已更改 [英] Status bar color changed when change UINavigationBar appearance backgroundimage

查看:699
本文介绍了更改UINavigationBar外观backgroundimage时状态栏颜色已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这行代码更改导航栏背景:

I use this line of code to change navigation bar background:

    [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"image.png"] forBarMetrics:UIBarMetricsDefault];

,但是在iOS5中,状态栏的背景也会改变,如图所示在此图像中:

in iOS6, it works, but in iOS5, background of the status bar is changed too, as shown in this image:

这是怎么发生的。在此先感谢。

how does this happen. Thanks in advance.

还有一件事,我只是想改变 UINavigationBar 的颜色,所以我用过这个代码:

One more thing, I just want to change the color of UINavigationBar, so I used this code:

[[UINavigationBar appearance] setTintColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]];

它适用于iOS6,但不适用于iOS5。是什么原因?

It works in iOS6 quite well, but does not in iOS5. What is the reason?

推荐答案

您可以使用此设置状态栏

You can use this one to set your status bar

 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];

因此状态栏颜色为黑色,字体颜色为白色..

So status bar colour will be black and font colour will be white..

这篇关于更改UINavigationBar外观backgroundimage时状态栏颜色已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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