我已经在应用委托设置标签栏颜色:iOS的7/8如何设置标签栏的文本颜色
[[UITabBar appearance] setTintColor:[UIColor redColor]];
它的工作完美,但我还需要单独设置文本颜色。我希望我的图像具有红色色调,但文字必须是白色。
这可能吗?
我已经在应用委托设置标签栏颜色:iOS的7/8如何设置标签栏的文本颜色
[[UITabBar appearance] setTintColor:[UIColor redColor]];
它的工作完美,但我还需要单独设置文本颜色。我希望我的图像具有红色色调,但文字必须是白色。
这可能吗?
改变uitabbaritem
颜色使用setTitleTextAttributes
我希望这段代码可以帮助您:
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [[uicolor whitecolor] }
forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }
forState:UIControlStateNormal];
改变形象tintcolor:
[[UITabBar appearance] setTintColor:[UIColor redcolor]];
的答案:https://stackoverflow.com/a/18734795/860343涵盖了大部分编辑的你可能需要为标签栏项目执行操作。
总之这里是代码:
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:10.0f],
NSForegroundColorAttributeName : appTintColor
} forState:UIControlStateSelected];
// doing this results in an easier to read unselected state then the default iOS 7 one
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:10.0f],
NSForegroundColorAttributeName : [UIColor colorWithRed:.5 green:.5 blue:.5 alpha:1]
} forState:UIControlStateNormal];
http://stackoverflow.com/questions/8412010/how-to-change-the-color-of-text-in-uitabbaritem-in-ios -5 – soulshined