uni-app map组件markers 设置 label的bgColor为rgba时出错

uni-app map组件markers 设置 label的bgColor为rgba时出错

### 表格

| 类别       | 信息          |
|------------|---------------|
| 开发环境   | Windows       |
| 操作系统版本号 | Windows 10    |
| 编辑器类型 | 正式          |
| 编辑器版本号 | 3.2.16        |
| 手机系统   | iOS           |
| 手机系统版本号 | iOS 15        |
| 手机厂商   | 苹果          |
| 手机机型   | iPhone 12     |
| 页面类型   | nvue          |
| Vue版本    | vue2          |
| 打包方式   | 离线          |
| 项目创建方式 | HBuilderX     |

### 操作步骤:
- map组件markers 设置 label的bgColor为ragb(255,255,255,0)或者transparent

### 预期结果:
- ios android 背景都可以透明

### 实际结果:
- android 透明 ,ios不透明

### bug描述:
- 离线打包,map组件markers 设置 label的bgColor为ragb(255,255,255,0) android可以实现透明,ios不行

更多关于uni-app map组件markers 设置 label的bgColor为rgba时出错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

此问题最版本已解决,离线打包需要更新离线sdk

更多关于uni-app map组件markers 设置 label的bgColor为rgba时出错的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的 iOS 平台兼容性问题。在 iOS 原生地图组件中,labelbgColor 对 rgba 透明值的支持存在限制。

解决方案:

  1. 使用十六进制带透明度颜色值:将 rgba(255,255,255,0) 改为 #00FFFFFF(前两位00表示透明度为0)。

  2. 检查拼写错误:您的代码中写的是 ragb,正确应为 rgba

  3. 平台条件编译:如果需要平台差异化处理,可以使用条件编译:

// #ifdef APP-IOS
bgColor: '#00FFFFFF',
// #endif
// #ifdef APP-ANDROID
bgColor: 'rgba(255,255,255,0)',
// #endif
回到顶部