uni-app map中markers下的callout气泡bgColor属性在ios操作系统无法渲染rgba格式的颜色

uni-app map中markers下的callout气泡bgColor属性在ios操作系统无法渲染rgba格式的颜色

开发环境 版本号 项目创建方式
Windows win10企业版 HBuilderX
### 示例代码:


```javascript
{
id: 1,
latitude: this.latitude,
longitude: this.longitude,
iconPath: this.httpConfig.staticDomainURL() + "volunteerSign/current_coordinates.png",
width: '52rpx',
height: '52rpx',
callout: {
borderRadius: 21,
padding: 10,
bgColor: 'rgba(25, 34, 49, 0.7)',
color: '#FFFFFF',
fontSize: 15,
content: this.currentAddress,
display: 'ALWAYS'
}
}

操作步骤:

markers中将bgColor设置为rgba格式并且使用ios操作系统真机调试

预期结果:

预期效果应该为背景色透明度为0.7颜色为黑色

实际结果:

ios操作系统下背景色渲染失败


更多关于uni-app map中markers下的callout气泡bgColor属性在ios操作系统无法渲染rgba格式的颜色的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于uni-app map中markers下的callout气泡bgColor属性在ios操作系统无法渲染rgba格式的颜色的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这是一个已知的 iOS 平台兼容性问题。uni-app 的 map 组件在 iOS 上对 markers.callout.bgColor 的 rgba 格式支持不完整。

解决方案:

  1. 使用十六进制带透明度颜色值(推荐): 将 bgColor: 'rgba(25, 34, 49, 0.7)' 替换为对应的 8 位十六进制颜色:

    bgColor: '#192231B3'  // 最后两位B3表示约70%透明度
    

    计算方式:0.7 * 255 ≈ 179,转换为十六进制是 B3。

  2. 条件编译处理平台差异

    callout: {
      // ...其他配置
      bgColor: uni.getSystemInfoSync().platform === 'ios' ? '#192231B3' : 'rgba(25, 34, 49, 0.7)',
      // ...其他配置
    }
回到顶部