我在我的选项卡式应用程序的各种视图控制器的'viewDidLoad‘中使用了以下代码。
UIColor *tabBarColor = [UIColor colorWithRed:85.1 green:57.6 blue:71.4 alpha:.5];
[[UITabBar appearance] setTintColor:tabBarColor];但我得到的图像应该是粉色的,是这样的:

我可以通过更改alpha来使其变亮或变暗,但从不着色--仅限黑/白/灰。
对如何解决这个问题有什么想法吗?
发布于 2012-12-03 14:55:24
在.m中的头文件下,将此行#define RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]写在您要设置颜色的位置,将此代码设置为粉红色[[UITabBar appearance] setTintColor:RGB(255, 192, 203)];,仅此而已
发布于 2012-12-03 14:48:48
试试这个:
if ([tabBarController.tabBar respondsToSelector:@selector(setTintColor:)])
{
[tabBarController.tabBar setTintColor: tabBarColor];
}发布于 2012-12-03 15:59:50
颜色必须在数字后面加上小数点:215.0/255。因为它是浮动的。
如果你想在32位和64位系统上精确地处理浮点数和双精度数,你还应该在数字后面加上f:215.0f/255。编译器会知道它是32位的。现在你的问题是你没有写分号:N_OF_COLORS / TOTAL_COLORS。
https://stackoverflow.com/questions/13678381
复制相似问题