【问题标题】:iPhone: UITabBar custom image doesn't workiPhone:UITabBar 自定义图像不起作用
【发布时间】:2010-08-17 10:13:00
【问题描述】:

我使用下面的 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

请指教。

谢谢。

【问题讨论】:

    标签: iphone objective-c


    【解决方案1】:

    我已经通过添加以下代码解决了这个问题:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-13
      相关资源
      最近更新 更多