Is there a way to use a custom selected image for UITabBarItem?

前端 未结 9 1976
滥情空心
滥情空心 2020-12-08 05:52

I like to have a custom selected image when a user selects an item on the tab bar, by default it selects as blue like but would like to have a green color instead. something

9条回答
  •  死守一世寂寞
    2020-12-08 06:33

    Just add some custom views (using insertSubview:atIndex:) when the UITabBarController-delegate-methods are called.

    Example:

    – (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
        [tabBarController.tabBar insertSubview:someView atIndex:someIndex];
    }
    

    You can try changing someIndex yourself till you have the result you want.

提交回复
热议问题