gpt4 book ai didi

react-native - 使用React Native检测iPhone iOS暗模式

转载 作者:行者123 更新时间:2023-12-03 11:11:57 25 4
gpt4 key购买 nike

我知道使用Swift可以做到这一点:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if traitCollection.userInterfaceStyle == .light {
print("Light mode")
} else {
print("Dark mode")
}
}

但是,有没有办法用JavaScript做到这一点?

最佳答案

从0.62.2开始,您就不需要react-native-dark-mode了。
您可以使用

import { Appearance } from 'react-native'
...
Appearance.getColorScheme() === 'dark'

这是添加的提交: https://github.com/facebook/react-native/commit/63fa3f21c5ab308def450bffb22054241a8842ef

关于react-native - 使用React Native检测iPhone iOS暗模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56821513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com