iOS 5 中的 UINavigationBar 外观覆盖
我有以下代码:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.72 alpha:1.0]];
但现在我想在我的应用程序中有一个位置,我希望导航栏的颜色与我在整个应用程序中设置的通用颜色不同。我如何才能仅针对此特定设置更改此设置。是否可以?
I have had the following code:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbarBackBlack.png"] forBarMetrics:UIBarMetricsLandscapePhone];
[[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:0.72 alpha:1.0]];
But now I want to have one place in my app where I want the navbar to be a different color than this universal color I've set throughout the app. How can I change this for this particular settings only. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也可以在导航栏的实例上调用 setBackgroundImage。
请参阅此相关帖子:
自定义 UITabBar 背景图像不在 iOS 5 及更高版本中工作
您还应该根据它是否响应该选择器来调整它:
You can call setBackgroundImage on the instance of the navigation bar as well.
See this related post:
Custom UITabBar background image not working in iOS 5 and later
You should also condition it on whether it responds to that selector:
只需直接在导航栏实例上使用外观方法,而不是在
appearance
代理对象上。Just use the appearance methods directly on the navigation bar instance instead on the
appearance
proxy object.