UITabBar appearance setSelectionIndicatorImage does not work on first launch iOS7

后端 未结 5 2342
你的背包
你的背包 2021-02-13 05:51

I have a customised UITabBar and use the following code in the AppDelegate:

- (void)tabBarController:(MainUITabBarController *)tabBarController didSelectViewCont         


        
5条回答
  •  故里飘歌
    2021-02-13 06:33

    Setting the selection indicator image for the tab bar directly once again, apart from doing it via appearance, worked for me!

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        ....
    
        UITabBarController *tabBarContr = (UITabBarController *)self.window.rootViewController;
        ...
        [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tab_bar_selection_indicator.png"]];
    
        // iOS7 hack: to make selectionIndicatorImage appear on the selected tab on the first app run
        [[tabBarContr tabBar] setSelectionIndicatorImage:[UIImage imageNamed:@"tab_bar_selection_indicator.png"]];
    
        return YES;
    }
    

提交回复
热议问题