2015-12-09 41 views
3

隨着tvOS 9.1和Xcode 7.2的發佈,我的UITabBarItem圖像顯示不正確。在我的視圖控制器中,我使用UIImageRenderingMode.AlwaysOriginal設置了tabBarItem.imagetabBarItem.selectedImage圖像。UITabBar顯示忽略渲染模式的UITabBarItem圖像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中顯示不正確。更糟糕的是,未選擇的圖像顯示爲黑色,並且選項卡欄背景也顯示爲黑色。

enter image description here

這裏是tvOS 9.0

enter image description here

我懷疑這是用tvOS 9.1的錯誤運行相同的代碼,但有沒有人找到了解決方法或看到,我不是東西正確地做?

+0

Apple支持已確認這是一個錯誤。 Apple提交的bug。 https://openradar.appspot.com/radar?id=5035170180628480 – picciano

+0

固定在tvOS 9.1.1。 – picciano

回答

1

它似乎肯定是tvOS 9.1的UITabBarController實現中的一個錯誤。所以我最終寫了自己的替代品。在此過程中,我添加了對超過7個標籤欄項目的支持,使它在黑色背景下看起來不錯,並且在其中一個標籤上也包含一個搜索欄(也在黑色背景上)。這解決了我嘗試構建我的第一個tvOS應用程序時遇到的許多困難。

Link to Github repository

enter image description here

1

我們在我們的tvos應用程序中看到類似的東西,除了我們使用文本而不是圖像。 tvOS 9.1忽略textColor。

UITabBarItem.appearance().setTitleTextAttributes([ 
    NSForegroundColorAttributeName: <barTextColor> 
], forState: UIControlState.Normal) 

UITabBarItem.appearance().setTitleTextAttributes([ 
    NSForegroundColorAttributeName: <barTextColorSelected>, 
], forState: UIControlState.Selected) 
+0

它工作不正常。 –

0

這被證實爲蘋果的錯誤,並已被固定在tvOS 9.1.1。

0

這可能對tvOS 9.1有幫助。此代碼寫入UITabBarControllerviewDidLoad()

for item in self.tabBar.items!{ 
      item.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.blackColor()], forState: UIControlState.Normal) 
      item.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.greenColor()], forState: UIControlState.Focused) 
     }