記錄適配iOS 13發(fā)現(xiàn)設(shè)置UITabBarItem的顏色,未選中狀態(tài)下無(wú)效為默認(rèn)顏色,選中狀態(tài)下有效,但是push后再返回,tabBarItem選中顏色變?yōu)橄到y(tǒng)藍(lán)色。適配方法提供如下
適配iOS13
if (@available(iOS 13.0, *)) {
// iOS13 及以上
//選中顏色
self.tabBar.tintColor = rgba(254, 204, 5, 1);
//默認(rèn)顏色
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];
}