2010-08-17 88 views
0

我使用以下UITTabBar和UINavigationBar內置代碼將我自己的自定義圖像放置在Tabbar和導航欄的背景上。它適用於我的iPhone 3.0應用程序。現在,我試圖將我的iPhone 3.0應用程序轉換爲iOS4.0。我現在在Xcode 3.2.3(對於iOS 4.0)中運行了相同的項目,但無法在Tabbar的背景下查看我的自定義Tabbar圖像。我試過調試它,但它根本不調用這個函數的UITabbar,但它同時調用UINavigationBar並且工作正常。這個函數(UITabbar)不存在(或)不能在iOS 4.0中使用嗎?iPhone:UITabBar自定義圖像不起作用

@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 

請指教。

謝謝。

回答

4

我已經通過添加以下代碼解決它:

[self.tabBarController.tabBar insertSubview:[ [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Tabbar.png"]] autorelease] atIndex:0]; 
+0

感謝answer..i真的stucked .. :) – iPhoneDev 2010-11-16 10:31:01

+0

+1和感謝ü這麼多漂亮的答覆.. :) – Sarah 2011-02-08 04:41:05