簡體   English   中英

iPhone:UITabBar自定義圖像不起作用

[英]iPhone: UITabBar custom image doesn't work

我使用以下UITTabBar和UINavigationBar內置代碼將自己的自定義圖像放置在Tabbar和Navigation bar的背景上。 它在我的iPhone 3.0應用程序中很好用。 現在,我正在嘗試將iPhone 3.0應用程序轉換為iOS4.0。 我現在在Xcode 3.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

請指教。

謝謝。

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM