UINavigationBar.layer.contents 在 IOS5 中不起作用,知道为什么吗?
我使用以下代码行来放置图像以显示 UINavigationBar 的背景,它在 IOS4 中工作正常,但在 IOS5 设备上不起作用。
UINavigationBar.layer.contents = (id)[UIImage imageNamed:@"header_bg_green.png"].CGImage;
另外,当我在 IOS 5 模拟器中测试它时,它不显示 UINavigationBar 层的图像。
请帮忙。
谢谢, 吉格尔
I am using the following line of code to place image to show background of a UINavigationBar, it works fine in IOS4 but not working on devices with IOS5.
UINavigationBar.layer.contents = (id)[UIImage imageNamed:@"header_bg_green.png"].CGImage;
Also when i test it in IOS 5 Simulator it do not show image for UINavigationBar layer.
Please help.
Thanks,
Jigar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 iOS 5 中,他们改变了在导航栏中自定义背景的方式。方法是:
如果你想在你的应用中同时支持 iOS 4 和 iOS 5,你需要做某种检查(例如使用
respondsToSelector
),然后有条件地使用旧的方式或者这个方法。In iOS 5 they changed the way you do custom backgrounds in navigation bars. The method is:
If you want to support both iOS 4 and iOS 5 in your app, you'll need to do some kind of check (such as using
respondsToSelector
), and then conditionally use either the old way or this method.