UITabBar屬性的設(shè)置

這些內(nèi)容通常寫(xiě)在+initialize方法里

//首先拿到UITabBar
UITabBar * tab = [UITabBar appearance];
//背景顏色
//tab.barTintColor = [UIColor yellowColor];
//前景顏色
//tab.tintColor = [UIColor orangeColor];
//設(shè)置背景圖片
[tab setBackgroundImage:[UIImage imageNamed:@"tabbar"]];
//設(shè)置透明度
tab.alpha = 0.3;
// UIControlStateNormal狀態(tài)下的文字屬性
 NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
//文字顏色
dictionary[NSForegroundColorAttributeName] = [UIColor blackColor];
//文字大小
dictionary[NSFontAttributeName] = [UIFont systemFontOfSize:12];

// UIControlStateSelected狀態(tài)下的文字屬性
NSMutableDictionary * seleDictionary = [NSMutableDictionary dictionary];
seleDictionary[NSForegroundColorAttributeName] = [UIColor colorWithRed:255 / 256.0 green:255 / 256.0  blue:130 / 256.0 alpha:1];

UITabBarItem * itme = [UITabBarItem appearance];
[itme setTitleTextAttributes:dictionary forState:UIControlStateNormal];
[itme setTitleTextAttributes:seleDictionary forState:UIControlStateSelected];
//每一個(gè)控制器都有tabBarItem這個(gè)屬性
childController.tabBarItem.image = [UIImage imageNamed:image];
childController.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
childController.tabBarItem.badgeValue = @"11";
//設(shè)置消息標(biāo)題的字體大小
[item setBadgeTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25]} forState:UIControlStateNormal];

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

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

  • 47.熟悉系統(tǒng)框架 將一系列代碼封裝為動(dòng)態(tài)庫(kù)(dynamic library),并在其中放入描述其接口的頭文件,這...
    Code_Ninja閱讀 1,255評(píng)論 0 4
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,007評(píng)論 25 709
  • 轉(zhuǎn)至元數(shù)據(jù)結(jié)尾創(chuàng)建: 董瀟偉,最新修改于: 十二月 23, 2016 轉(zhuǎn)至元數(shù)據(jù)起始第一章:isa和Class一....
    40c0490e5268閱讀 2,043評(píng)論 0 9
  • 人人都?jí)粝胫腋5厣?,而幸福的一個(gè)要點(diǎn)就是感覺(jué)到和諧,在和諧的環(huán)境中獲得和諧的感覺(jué)。我們所生存的社會(huì),會(huì)因?yàn)榈赜?..
    丠小龍閱讀 2,340評(píng)論 2 11
  • 小時(shí)候,總是被激勵(lì)著說(shuō),只要功夫深,鐵棒磨成針,以為自己能夠“水滴石穿”的達(dá)到自己所有的目標(biāo)。 及之長(zhǎng)大,才知道人...
    菱角滿(mǎn)塘閱讀 833評(píng)論 1 2

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