我使用下面的UITTabBar和UINavigationBar内置代码将我自己的自定义图像放在Tabbar和导航栏的背景上。它在我的iPhone 3.0应用程序中工作得很好。现在,我正在尝试将我的IOS3.0应用程序转换为iPhone 4.0。我现在在Xcode3.2.3(适用于iOS 4.0)中运行了相同的项目,但无法在Tabbar的背景中查看我的自定义Tabbar图像。我试着调试它,但它根本没有调用这个函数UITabbar,但同时它调用UINavigationBar也很好,并且工作正常。这个函数(UITabbar)是不存在(或者)不能在iOS 4.0中使用吗?
@implementation UITabBar(CustomImage)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"Tabbar.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawRect:(CGRect)rect {
UIImage *image = [UIImage imageNamed: @"NavigationImage.png"];
[image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end请给我建议。
谢谢。
发布于 2010-08-18 19:22:05
我已经通过添加下面的代码解决了这个问题:
[self.tabBarController.tabBar insertSubview:[ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tabbar.png"]] autorelease] atIndex:0];https://stackoverflow.com/questions/3501363
复制相似问题