ios4中的导航栏自定义在ios5中不起作用 [英] Navigation Bar customization in ios4 doesnt work in ios5

查看:75
本文介绍了ios4中的导航栏自定义在ios5中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题与这里的其他问题相同,但是他们都没有说关于ios4和ios5之间不兼容的任何事情。

i know that this question looks the same as other around here, but none of them say anything about incompatibility between ios4 and ios5.

在我的应用中,我想自定义导航栏的模式,但是我的部署目标是ios4,所以我使用appDelegate.m实施上方的以下代码来做到这一点:

In my app i want to customize the pattern of the navigation Bar, but my deployment target is ios4, so i am using the code bellow above the implementation of the appDelegate.m to do this:

@implementation UINavigationBar (CustomImage)

- (void)drawRect:(CGRect)rect {
UIColor *color = [UIColor blackColor];
UIImage *image = [UIImage imageNamed: @"nav_bar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
self.tintColor = color;
}

@end

当我使用4.3模拟器,它可以正常工作,但是当我在ios5中模拟时,它不起作用,导航栏会恢复为默认颜色。有什么帮助吗?

When i run the app using the 4.3 simulator, it works properly, but when i simulate in ios5, it doesnt work, the nav bar goes back to the default color.. any help?

谢谢。

推荐答案

我建议在iOS4上运行时使用您现有的代码,并使用新的iOS5功能自定义iOS5下的栏

I'd recommend using your existing code when running on iOS4, and using the new iOS5 features to customize the bar under iOS5.

请参见此处:在iOS 5.0中未调用UINavigationBar的drawRect

这篇关于ios4中的导航栏自定义在ios5中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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