UITabBar設(shè)置

    [UITabBar appearance].barStyle = UIBarStyleDefault;
    [self.tabBar setBackgroundColor:[UIColor blueColor]];

    //設(shè)置字體顏色
    // 適配iOS13
    if (@available(iOS 13.0, *)) {
        // iOS13 及以上
        self.tabBar.tintColor = [UIColor redColor];
        self.tabBar.unselectedItemTintColor = [UIColor yellowColor];
    }
    else {
        // iOS13 以下
        UITabBarItem *item = [UITabBarItem appearance];
        NSMutableDictionary *attrNor = [NSMutableDictionary dictionary];
        attrNor[NSForegroundColorAttributeName] = [UIColor redColor];
        [[UITabBarItem appearance] setTitleTextAttributes:attrNor forState:UIControlStateNormal];
        
        NSMutableDictionary *attrSel = [NSMutableDictionary dictionary];
        attrSel[NSForegroundColorAttributeName] = [UIColor blueColor];
        [[UITabBarItem appearance] setTitleTextAttributes:attrSel forState:UIControlStateSelected];
    }

注意如果展現(xiàn)的icon和UI圖不符,記得設(shè)置圖片展示模式

VC.tabBarItem.image = [[LSMHelper imageNamed:@"livesteam_square"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 用兩張圖告訴你,為什么你的 App 會卡頓? - Android - 掘金 Cover 有什么料? 從這篇文章中你...
    hw1212閱讀 13,966評論 2 59
  • Desktop Window Manager 本文翻譯自 MSDN 從 Vista 開始引進的 Desktop c...
    董噠噠閱讀 5,849評論 0 1
  • github排名https://github.com/trending,github搜索:https://gith...
    小米君的demo閱讀 4,952評論 2 38
  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 15,211評論 4 61
  • 內(nèi)容抽屜菜單ListViewWebViewSwitchButton按鈕點贊按鈕進度條TabLayout圖標(biāo)下拉刷新...
    皇小弟閱讀 47,147評論 22 665

友情鏈接更多精彩內(nèi)容