屏幕旋转之后,UITabBarItem选种颜色不正确
// 适配iOS13导致的bug
if (@available(iOS 13.0, *)) {
// iOS 13以上
self.tabBar.tintColor = kThemeColor;
self.tabBar.unselectedItemTintColor = [UIColor z_colorWithRGBHex:0x999999];
UITabBarItem *item = [UITabBarItem appearance];
item.titlePositionAdjustment = UIOffsetMake(0, -2);
[item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} forState:UIControlStateSelected];
} else {
// iOS 13以下
UITabBarItem *item = [UITabBarItem appearance];
item.titlePositionAdjustment = UIOffsetMake(0, -2);
[item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[UIColor z_colorWithRGBHex:0x999999]} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:kThemeColor} forState:UIControlStateSelected];
}