一、用storyboard建立的Tab bar,不能改变它的字体颜色。 如果用storyboard建立TabBarController,那么想要选择Bar Tint改变字体的颜色是不行滴。这时候,应该新建一个新的类“RetabBar”继承自TabBar。 在.h文件中声明属性
@interface RetabBar : UITabBar
@property (nonatomic, strong)IBInspectable UIColor *tabBartintColor;
@end
在这段代码中的“IBInspectable”其实就是充当一个桥梁,将自定义的代码实时渲染到Interface Builder中。在swift语言中则是用@IBDesignable。它的使用规则是写在@class之前即可。 在.m文件中的setter方法中,设置tabbar的tintColor。
-(void)setTabBartintColor:(UIColor *)tabBartintColor
{
self.tintColor = tabBartintColor;
}
接下来将storyboard中的tab bar绑定到RetabBar类上,就会出现如下效果。
接下来就可以设置tabbar字体的颜色了。