How to set image background to UITabBarController iOS 5

后端 未结 3 588
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 16:44

Hello can someone help me with this pice of code. I have app with custom tab bar image an now in iOS5 the image is gone. I know that they have made changes on tab bar implem

相关标签:
3条回答
  • 2021-01-03 17:23
    // Change the tab bar background
    UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
    [[UITabBar appearance] setBackgroundImage:tabBarBackground];
    
    0 讨论(0)
  • 2021-01-03 17:37

    Use this code to detect iOS version

    if ([[[UIDevice currentDevice] systemVersion] floatValue] < 5)  {
        [[tabBarController tabBar] insertSubview:viewa atIndex:0];
    }else{
        [[tabBarController tabBar] insertSubview:viewa atIndex:1];
    }
    
    0 讨论(0)
  • 2021-01-03 17:40

    Change source as below, you can fix this problem.

    Old source:

    [[tabBarController tabBar] insertSubview:viewa atIndex:0];
    

    New source:

    //1.Check version of iOS
    if(iOSVersion <= 4.3){
        [[tabBarController tabBar] insertSubview:viewa atIndex:0];
    }else{
    //iOS5
        [[tabBarController tabBar] insertSubview:viewa atIndex:1];
    }
    
    0 讨论(0)
提交回复
热议问题