how to change UITabbar selected color?

后端 未结 4 1488
礼貌的吻别
礼貌的吻别 2020-12-18 14:02

according to this post for now, Is apple will also reject this code?

and how to implement what apple will approve?

@interface UITabBar (ColorExtensi         


        
4条回答
  •  抹茶落季
    2020-12-18 14:42

    I suggest instead of changing color why don't you use selected tabbaritem image, like In iOS 6 I have change the selected tabbatitem image like -

    in tabbar controller delegate method

    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    
    {
        if([tabBarController selectedIndex] == 0)
        {
            [viewController.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"selected.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"unselect.png"]];
        }    
    }
    

    through this you can change your image.

    Or you can use directly in your view controllers init(or ViewWillAppear) method, like

            [viewController.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"selected.png"]withFinishedUnselectedImage:[UIImage imageNamed:@"unselect.png"]];
    

提交回复
热议问题