gpt4 book ai didi

uitabbarcontroller - 如何更改 iOS 7 中 tabBarItems 的文本和图标颜色?

转载 作者:行者123 更新时间:2023-12-03 01:39:51 31 4
gpt4 key购买 nike

如何更改 iOS 7 中 UITabBar 和 UITabBarItems 的文本和图标颜色?对于未选择的选项卡栏项目,默认的灰色文本显得暗淡且难以阅读。

最佳答案

为此您需要做两件事:

1)如果要自定义TabBar本身,需要为tabBarController设置barTintColor:

    // this will generate a black tab bar
tabBarController.tabBar.barTintColor = [UIColor blackColor];

// this will give selected icons and text your apps tint color
tabBarController.tabBar.tintColor = appTintColor; // appTintColor is a UIColor *

2) 为要覆盖的每个状态设置 tabBarItem 文本外观:

[[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];

关于uitabbarcontroller - 如何更改 iOS 7 中 tabBarItems 的文本和图标颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18734794/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com