记录适配iOS 13发现设置UITabBarItem的颜色,未选中状态下无效为默认颜色,选中状态下有效,但是push后再返回,tabBarItem选中颜色变为系统蓝色。适配方法提供如下
适配iOS13
if (@available(iOS 13.0, *)) {
// iOS13 及以上
//选中颜色
self.tabBar.tintColor = rgba(254, 204, 5, 1);
//默认颜色
self.tabBar.unselectedItemTintColor = rgba(153, 153, 153, 1);
}
else {
// iOS13 以下
UITabBarItem *item = [UITabBarItem appearance];
[item setTitleTextAttributes:@{ NSForegroundColorAttributeName:rgba(153, 153, 153, 1)} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{ NSForegroundColorAttributeName:rgba(254, 204, 5, 1)} forState:UIControlStateSelected];
}
网友评论