[英]iPhone: UITabBar custom image doesn't work
I use the following UITTabBar and UINavigationBar built-in code to place my own custom image on the background of Tabbar and Navigation bar. 我使用以下UITTabBar和UINavigationBar内置代码将自己的自定义图像放置在Tabbar和Navigation bar的背景上。 It works great in my iPhone 3.0 application.
它在我的iPhone 3.0应用程序中很好用。 Now, i am trying to convert my iPhone 3.0 application to iOS4.0.
现在,我正在尝试将iPhone 3.0应用程序转换为iOS4.0。 I ran the same project in Xcode 3.2.3(for iOS 4.0) now but unable to view my custom Tabbar image in the background of Tabbar.
我现在在Xcode 3.2.3(适用于iOS 4.0)中运行了相同的项目,但是无法在Tabbar的背景下查看我的自定义Tabbar图像。 I tried debugging it, but it is not calling to this function UITabbar at all, but the same time it calls UINavigationBar well and works.
我尝试对其进行调试,但它根本没有调用此函数UITabbar,但与此同时,它很好地调用了UINavigationBar并且可以正常工作。 Is this function(UITabbar) not there (or) can't use in iOS 4.0?
此功能(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
Please advise. 请指教。
Thank you. 谢谢。
我通过添加以下代码解决了它:
[self.tabBarController.tabBar insertSubview:[ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tabbar.png"]] autorelease] atIndex:0];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.