iOS 设置 UITabBarItem 选中图片的颜色和字体

- (void)setTabBarItem:(UITabBarItem*)tabbarItem

Title:(NSString*)title

withTitleSize:(CGFloat)size

andFoneName:(NSString*)foneName

selectedImage:(NSString*)selectedImage

withTitleColor:(UIColor*)selectColor

unselectedImage:(NSString*)unselectedImage

withTitleColor:(UIColor*)unselectColor{

//设置图片

tabbarItem = [tabbarIteminitWithTitle:titleimage:[[UIImageimageNamed:unselectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]selectedImage:[[UIImageimageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

//未选中字体颜色

[[UITabBarItemappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:unselectColor,NSFontAttributeName:[UIFontfontWithName:foneNamesize:size]}forState:UIControlStateNormal];

//选中字体颜色

[[UITabBarItemappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:selectColor,NSFontAttributeName:[UIFontfontWithName:foneNamesize:size]}forState:UIControlStateSelected];

}

[selfsetTabBarItem:homeNC.tabBarItem

Title:@"首页"

withTitleSize:14.0

andFoneName:@"Marion-Italic"

selectedImage:@"orderError"

withTitleColor:[UIColorredColor]

unselectedImage:@"orderSuccess"

withTitleColor:[UIColorwhiteColor]];

你可能感兴趣的:(iOS 设置 UITabBarItem 选中图片的颜色和字体)