IPhone: UITabBar custom image not working

I use the following built-in UITTabBar and UINavigationBar code to place my own image on the background of the Tabbar and navigation bar. It works great in my iPhone 3.0 app. Now I am trying to convert an iPhone 3.0 application to iOS4.0. Now I ran the same project in Xcode 3.2.3 (for iOS 4.0), but could not view my own tab image in the background of the Tabbar. I tried to debug it, but it doesn’t call this UITabbar function at all, but at the same time it works well and works with the UINavigationBar. This function (UITabbar) does not exist (or) cannot be used in 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 inform.

Thank.

0
source share
1

, :

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

Source: https://habr.com/ru/post/1769955/


All Articles