0

First of all, I tried this link in didFinishLaunchingWithOptions. It always return unspecified in my apple tv simulator. Is there have any other solution to check which appearance style has been set on apple tv settings?

I want to change my tvOS app's theme respect to dark or light appearance style.

Community
  • 1
  • 1
anas.p
  • 2,246
  • 19
  • 26

1 Answers1

1

You need to check current style in traitCollectionDidChange and update UI there.

From Apple documentation

Implement this method in view controllers and views, according to your app’s needs, to respond to such changes.

Sample usage

class DetailsHeaderCell: UICollectionViewCell {
    @IBOutlet private(set) var title: UILabel!

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)

        title.layer.borderColor = 
            traitCollection.userInterfaceStyle == .dark ? 
        UIColor.white.cgColor : UIColor.black.cgColor
    }    
}
JaanusSiim
  • 2,192
  • 3
  • 22
  • 24
  • how I implement "traitCollectionDidChange" in swift3 programming. Can you please give a sample code?. – anas.p Feb 23 '17 at 12:48
  • Sounds like `traitCollectionDidChange` would only be called if the user changed the appearance when using the application. You can check the appearance style with `UIUserInterfaceStyle`: http://stackoverflow.com/a/39562883/2108547 – Daniel Storm Feb 23 '17 at 18:46