您的位置:首页 > 其它

设置tabbaritem的title颜色(选中和未选中)

2016-02-22 15:22 495 查看
#define UIColorFromRGB(rgbValue) \
[UIColor colorWithRed:((float)((rgbValue &
0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >>
8))/255.0 \
blue:((float)((rgbValue & 0x0000FF) >>
0))/255.0 \
alpha:1.0]
//点击之后的颜色:草绿
#define COLOR_HIGHTLIGHT UIColorFromRGB(0x129190)
//白色
#define COLOR_THEME_FONT UIColorFromRGB(0xffffff)

-------------关键代码---------------
NSDictionary *attributes =
[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont

fontWithName:@"Helvetica"
size:10],
NSFontAttributeName,
COLOR_THEME_FONT,
NSForegroundColorAttributeName,
nil];
[[UITabBarItem
appearance] setTitleTextAttributes:attributes
forState:UIControlStateNormal];

NSDictionary *attributes2 =
[NSDictionary
dictionaryWithObjectsAndKeys:[UIFont
fontWithName:@"Helvetica"
size:10],
NSFontAttributeName,
COLOR_HIGHTLIGHT,
NSForegroundColorAttributeName,
nil];
[[UITabBarItem
appearance] setTitleTextAttributes:attributes2
forState:UIControlStateSelected];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: