我知道这可以使用 Swift:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if traitCollection.userInterfaceStyle == .light {
print("Light mode")
} else {
print("Dark mode")
}
}
Run Code Online (Sandbox Code Playgroud)
但是,有没有办法用 JavaScript 做到这一点?
小智 24
你不需要react-native-dark-mode因为0.62.2。您可以使用
import { Appearance } from 'react-native'
...
Appearance.getColorScheme() === 'dark'
Run Code Online (Sandbox Code Playgroud)
这是添加它的提交:https : //github.com/facebook/react-native/commit/63fa3f21c5ab308def450bffb22054241a8842ef
| 归档时间: |
|
| 查看次数: |
7063 次 |
| 最近记录: |