//主题设置
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar-light"]];
NSDictionary * dict = @{
NSFontAttributeName : [UIFont systemFontOfSize:14],
NSForegroundColorAttributeName : [UIColor grayColor]
};
//key 定义在NSAttributedString.h
NSDictionary * selectDict = @{NSForegroundColorAttributeName : [UIColor darkGrayColor]};
UITabBarItem * item = [UITabBarItem appearance];
[item setTitleTextAttributes:dict forState:UIControlStateNormal];
[item setTitleTextAttributes:selectDict forState:UIControlStateSelected];
本文介绍如何在iOS应用中使用代码设置UITabBar的背景图片和UITabBarItem的文字属性,包括字体大小、未选中和选中状态的颜色。
1万+

被折叠的 条评论
为什么被折叠?



