UITabBar属性的设置

这些内容通常写在+initialize方法里

//首先拿到UITabBar
UITabBar * tab = [UITabBar appearance];
//背景颜色
//tab.barTintColor = [UIColor yellowColor];
//前景颜色
//tab.tintColor = [UIColor orangeColor];
//设置背景图片
[tab setBackgroundImage:[UIImage imageNamed:@"tabbar"]];
//设置透明度
tab.alpha = 0.3;
// UIControlStateNormal状态下的文字属性
 NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
//文字颜色
dictionary[NSForegroundColorAttributeName] = [UIColor blackColor];
//文字大小
dictionary[NSFontAttributeName] = [UIFont systemFontOfSize:12];

// UIControlStateSelected状态下的文字属性
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];
//每一个控制器都有tabBarItem这个属性
childController.tabBarItem.image = [UIImage imageNamed:image];
childController.tabBarItem.selectedImage = [UIImage imageNamed:selectImage];
childController.tabBarItem.badgeValue = @"11";
//设置消息标题的字体大小
[item setBadgeTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:25]} forState:UIControlStateNormal];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 47.熟悉系统框架 将一系列代码封装为动态库(dynamic library),并在其中放入描述其接口的头文件,这...
    Code_Ninja阅读 1,267评论 0 4
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 179,540评论 25 708
  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 2,116评论 0 9
  • 人人都梦想着幸福地生活,而幸福的一个要点就是感觉到和谐,在和谐的环境中获得和谐的感觉。我们所生存的社会,会因为地域...
    丠小龙阅读 2,361评论 2 11
  • 小时候,总是被激励着说,只要功夫深,铁棒磨成针,以为自己能够“水滴石穿”的达到自己所有的目标。 及之长大,才知道人...
    菱角满塘阅读 834评论 1 2

友情链接更多精彩内容