How to set UITabBarItem's unselected tint, ***including system items*** (iOS7)

前端 未结 6 933
灰色年华
灰色年华 2020-12-14 08:43

(NOTE: I see there are several similar questions on SO, but none of them seem to get at my specific issue of wanting to change the unselected appearance of

6条回答
  •  情深已故
    2020-12-14 09:34

    Are you up for some private API use?

    Do this sometime after the tab bar has been populated:

    for (UIView *v in self.tabBar.subviews)
      if ([NSStringFromClass(v.class) isEqual:@"UITabBarButton"])
        [v performSelector:@selector(_setUnselectedTintColor:)
                  withObject:[UIColor whiteColor]];
    

    Usual warnings about private API apply: Apple would rather you not do this; if it breaks you get to keep both pieces; etc.

    The example code is not particularly stealthy with regard to App Store review. Apple will catch it, as presented. Add your favorite stealth techniques to suit.

    Works on at least iOS 7.0.1 and 7.1.

提交回复
热议问题