之前都会自定义一个UIView或者toolbar来代替UITabBar,今天终于找了一下如何很好的定义UITabBar(以下内容适用于iOS7)
1、字体颜色
[tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
这个TextAttributes就是一般的NSAttribute的属性,具体设置可以百度
2、图片颜色(放上去的图片自动就变成了灰色,很恼人)
tabBarItem.image = [[UIImage imageNamed:@"bt_highlight_image.jpg"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
3、TabBar的背景颜色,这个可以直接在storyboard中设置Bar tint
4、被选中后那一块的背景图片,这个也可以在storyboard中Tab Bar中selection设置