系統默認的tabbar感覺好小,很丑,於是得自己來設置它的大小
我們需要在
+(void)load 或者在 +(void)initialize 里設置
那這兩個方法有什么區別呢
可以看這里 :(轉載)http://www.jianshu.com/p/9368ce9bb8f9
我們在這里是用load方法
//在自定義tabbar中的控制器里
+ (void)load
{
// 獲取當前類的tabBarItem
UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
// 設置所有item的選中時顏色
// 設置選中文字顏色
// 創建字典去描述文本
NSMutableDictionary *attr = [NSMutableDictionary dictionary];
// 文本顏色 -> 描述富文本屬性的key -> NSAttributedString.h
attr[NSForegroundColorAttributeName] = [UIColor blackColor];
[item setTitleTextAttributes:attr forState:UIControlStateSelected];
// 通過normal狀態設置字體大小
// 字體大小 跟 normal
NSMutableDictionary *attrnor = [NSMutableDictionary dictionary];
// 設置字體
attrnor[NSFontAttributeName] = [UIFont systemFontOfSize:13];
[item setTitleTextAttributes:attrnor forState:UIControlStateNormal];
}
