gpt4 book ai didi

objective-c - iOS 7,未选择的色调?

转载 作者:行者123 更新时间:2023-12-04 04:40:40 25 4
gpt4 key购买 nike

我正在升级我的应用程序以满足 iOS 7 准则。我的主标签栏 Controller 具有蓝色背景,默认的灰色“未选择”色调使图标几乎不可见。如何更改这些图标的色调?我希望它们是黑色或与蓝色背景形成鲜明对比的颜色。

我已经使用 window.TintColor = White 配置了一个应用程序范围的色调,但这只会改变选定的颜色。 (与 TabBar.TintColor 相同)

最佳答案

我还没有测试过,但不幸的是,这个答案看起来是唯一的解决方案
https://stackoverflow.com/a/18433996/1732987

更新:为后代复制代码。

// set color of selected icons and text to red
self.tabBar.tintColor = [UIColor redColor];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor], UITextAttributeTextColor, nil] forState:UIControlStateSelected];


// set color of unselected text to green
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor], UITextAttributeTextColor, nil]
forState:UIControlStateNormal];

// set selected and unselected icons
UITabBarItem *item0 = [self.tabBar.items objectAtIndex:0];

// this way, the icon gets rendered as it is (thus, it needs to be green in this example)
item0.image = [[UIImage imageNamed:@"unselected-icon.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

// this icon is used for selected tab and it will get tinted as defined in self.tabBar.tintColor
item0.selectedImage = [UIImage imageNamed:@"selected-icon.png"];

关于objective-c - iOS 7,未选择的色调?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18930386/

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