一、如果只是設(shè)置選中狀態(tài)的字體顏色,使用 tintColor 就可以達(dá)到效果
self.tabBar.tintColor = [UIColor redColor];二、但如果要將未選中狀態(tài)和選中狀態(tài)下的顏色都改變,可以使用 setTitleTextAttributes:<#(nullable NSDictionary<NSString *,id> *)#> forState:<#(UIControlState)#> 達(dá)到效果[nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];[nav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateSelected]; 或者[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal];[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateSelected];
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注