uni-app iOS配置暗黑模式后,uni.showActionSheet显示深色,uni.showLoading仍是白色背景
uni-app iOS配置暗黑模式后,uni.showActionSheet显示深色,uni.showLoading仍是白色背景
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Mac | 11.2.3 | CLI |
操作步骤:
- 调用 uni.showLoading
预期结果:
- 背景深色
实际结果:
- 背景白色
bug描述:
- ios 配置暗黑模式后,uni.showActionSheet 显示是深色,uni.showLoading 仍是 白色背景。
更多关于uni-app iOS配置暗黑模式后,uni.showActionSheet显示深色,uni.showLoading仍是白色背景的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这么久了 深色模式的showLoading框还是白色背景
更多关于uni-app iOS配置暗黑模式后,uni.showActionSheet显示深色,uni.showLoading仍是白色背景的实战教程也可以访问 https://www.itying.com/category-93-b0.html
onLaunch: function() {
// 强制设置UI模式为浅色,解决IOS暗黑模式下弹窗为白色的问题
plus.nativeUI.setUIStyle(‘light’);
}
到目前为止还是有这个bug,而且iOS暗黑模式下,input输入框内一片空白。
checkbox文字也显示不出来。
在iOS暗黑模式下,uni.showLoading组件未自动适配深色主题是已知的兼容性问题。这是因为uni-app底层对iOS系统深色模式的适配尚未完全覆盖所有组件。
解决方案:
- 使用条件渲染手动控制样式:
uni.showLoading({
title: '加载中',
mask: true,
success: () => {
// 通过判断系统主题动态设置背景色
if(uni.getSystemInfoSync().theme === 'dark') {
// 可配合修改全局样式变量
}
}
})
-
使用原生能力替代: 通过uni.requireNativePlugin调用iOS原生MBProgressHUD等控件,这些控件默认支持深色模式适配。
-
临时方案: 使用uni.showModal替代showLoading,或自定义loading组件,通过css媒体查询实现深色适配:
[@media](/user/media) (prefers-color-scheme: dark) {
.custom-loading {
background-color: #1c1c1e;
}
}

