如何检查用户是否在 Apple TV 上启用了深色外观?
Using UI用户界面样式 https://developer.apple.com/reference/uikit/uiuserinterfacestyle,首先在 tvOS 10 中提供,我们可以检查用户设置的外观。
例如:
func checkInterfaceStyle() {
guard(traitCollection.responds(to: #selector(getter: UITraitCollection.userInterfaceStyle)))
else { return }
let style = traitCollection.userInterfaceStyle
switch style {
case .light:
print("light")
case .dark:
print("dark")
case .unspecified:
print("unspecified")
}
}
另外,如果您从 Xcode 7/tvOS 9.0 项目进行更新,则需要包含UIUserInterfaceStyle
在你的info.plist
。使用 Xcode 8 创建的新项目已包含此密钥。
<key>UIUserInterfaceStyle</key>
<string>Automatic</string>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)