修改UITabBarItem的(de)字體顔色 - 新聞資訊 - 雲南小程序開發|雲南軟件開發|雲南網站建設-昆明融晨信息技術有限公司

159-8711-8523

雲南網建設/小程序開發/軟件開發

知識

不(bù)管是(shì)網站,軟件還是(shì)小程序,都要(yào / yāo)直接或間接能爲(wéi / wèi)您産生價值,我們在(zài)追求其視覺表現的(de)同時(shí),更側重于(yú)功能的(de)便捷,營銷的(de)便利,運營的(de)高效,讓網站成爲(wéi / wèi)營銷工具,讓軟件能切實提升企業内部管理水平和(hé / huò)效率。優秀的(de)程序爲(wéi / wèi)後期升級提供便捷的(de)支持!

您當前位置>首頁 » 新聞資訊 » 技術分享 >

修改UITabBarItem的(de)字體顔色

發表時(shí)間:2021-1-10

發布人(rén):融晨科技

浏覽次數:55

修改UITabBarItem下面字體的(de)顔色,如圖:


[img]http://img.blog.csdn.net/20150108133337062

[[UITabBarItemappearance] setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorblackColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal];
    [[UITabBarItemappearance] setTitleTextAttributes:   [NSDictionarydictionaryWithObjectsAndKeys:[UIColorredColor],UITextAttributeTextColor,nil]forState:UIControlStateSelected];
這(zhè)個(gè)時(shí)候會報警告'UITextAttributeTextColor' is deprecated in iOS 7. The iOS 7 key is 'NSForegroundColorAttributeName

然後替換一下就(jiù)可以(yǐ)了(le/liǎo),不(bù)過NSForegroundColorAttributeName最底支持到(dào)ios6.0
[[UITabBarItemappearance] setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorblackColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
    [[UITabBarItemappearance] setTitleTextAttributes:  [NSDictionarydictionaryWithObjectsAndKeys:[UIColorredColor],NSForegroundColorAttributeName,nil]forState:UIControlStateSelected];
以(yǐ)上(shàng)是(shì)改變字體顔色的(de),圖片顔色無法改變,
[[UITabBar appearance]setTintColor:[UIColor redColor]];
但是(shì)上(shàng)面這(zhè)一句就(jiù)可以(yǐ)改變并設置點擊後的(de)圖片和(hé / huò)文字顔色了(le/liǎo)。

相關案例查看更多