2017-08-23 17 views
0

tabBarアイテムに選択状態とフォーカス状態に異なるタイトルの色を付けるにはどうすればよいですか?tvOSでUITabBarItemが選択され、フォーカスされている状態

タイトルテキストの属性を設定していますが、選択状態とフォーカス状態の間に違いはありません。常に同じ色です。ここで

は、私はタブバーのアイテムを作成する方法である:

for title in titlesArray { 

     let item = UITabBarItem(title: title, image: nil, selectedImage: nil) 
     item.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(white: 1, alpha: 1)], for: .selected) 
     item.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(white: 1, alpha: 0.2)], for: .normal) 
     item.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blue], for: .focused) 

     tabBarItems.append(item) 
    } 

    tabbar.items = tabBarItems 

いずれかが、私はこれを達成する方法を理解するのに役立ちます。ありがとう。

答えて

0

それはとにかくで助けることができる場合は、これを試してみてください:通常の場合

を:

UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.grayColor()], forState:.Normal) 

と選択のために:

UITabBarItem.appearance().setTitleTextAttribute([NSForegroundColorAttributeName:UIColor.redColor()], forState:.Selected) 
+0

私の質問は:どのように私は、タブバーの項目に別のタイトルの色を与えることができます選択され焦点を合わせられた状態のために?通常の状態と選択された状態では、何が行われているのかが分かります。 –

+0

これは何らかの方法で役立ちますか?https://stackoverflow.com/questions/34433009/how-to-change-tab-bar-item-text-colour-on-focus-in-tvos – Amit

関連する問題