随着tvOS 9.1和Xcode 7.2的发布,我的UITabBarItem
图像显示不正确。在我的视图控制器中,我使用tabBarItem.image
将tabBarItem.selectedImage
和UIImageRenderingMode.AlwaysOriginal
设置为图像。
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.tabBarItem.image = UIImage(named: "myTabImage")?.imageWithRenderingMode(.AlwaysOriginal)
self.tabBarItem.selectedImage = UIImage(named: "myTabImageSelected")?.imageWithRenderingMode(.AlwaysOriginal)
}
所选图像显示正确,但未选中的图像显示为模板,即忽略其颜色信息。
使用tvOS 9.0 SDK正确显示两个图像,但未选中的图像在tvOS 9.1中显示不正确。更糟糕的是,未选择的图像显示为黑色,标签栏背景也显示为黑色。
这是在tvOS 9.0上运行的相同代码
我怀疑这是tvOS 9.1的一个错误,但有没有人找到解决方法或看到我做得不对的东西?
答案 0 :(得分:1)
我们在tvos应用程序中看到类似的东西,除了我们使用文本而不是图像。 tvOS 9.1忽略textColor。
UITabBarItem.appearance().setTitleTextAttributes([
NSForegroundColorAttributeName: <barTextColor>
], forState: UIControlState.Normal)
UITabBarItem.appearance().setTitleTextAttributes([
NSForegroundColorAttributeName: <barTextColorSelected>,
], forState: UIControlState.Selected)
答案 1 :(得分:1)
它似乎肯定是tvOS 9.1的UITabBarController实现中的一个错误。所以我最后写了自己的替代品。在此期间,我添加了对超过7个标签栏项目的支持,使其在黑色背景上看起来很漂亮,并在其中一个选项卡上包含搜索栏(也在黑色背景上)。这解决了我在尝试构建我的第一个tvOS应用程序时遇到的许多困难。
答案 2 :(得分:0)
这被Apple确认为一个错误,并已在tvOS 9.1.1中修复。
答案 3 :(得分:0)
它可能对tvOS 9.1有所帮助。此代码会写入viewDidLoad()
的{{1}}。
UITabBarController