gpt4 book ai didi

ios - MGLPolyLine 颜色更改不起作用 - Swift 4、Mapbox

转载 作者:行者123 更新时间:2023-11-29 06:01:39 25 4
gpt4 key购买 nike

当我尝试更改 MGLPolyline 的颜色时,应用程序崩溃并打印此 fatal error (它也需要我:

Assertion failed: (r_ <= 1.0f), function Color, file /Users/distiller/project/include/mbgl/util/color.hpp, line 18.

我正在使用 Mapbox。这是我用来更改颜色的代码:

//Colors:
let orangeColor = UIColor(red: 253, green: 70, blue: 2, alpha: 100)
let purpleColor = UIColor(red: 101, green: 0, blue: 141, alpha: 100)
let redColor = UIColor(red: 254, green: 0, blue: 0, alpha: 100)
let pinkPurpColor = UIColor(red: 193, green: 6, blue: 245, alpha: 100)
let pinkColor2 = UIColor(red: 254, green: 0, blue: 131, alpha: 100)

func mapView(_ mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {

let arrayOfColors = [pinkColor2, pinkPurpColor, redColor, purpleColor, orangeColor]

let randomIndex = Int(arc4random_uniform(UInt32(arrayOfColors.count)))

return arrayOfColors[randomIndex]
}

最佳答案

值 < 1 且除法 255。

swift 4.2

你能试试这个代码吗

let orangeColor = UIColor(red: 253/255, green: 70/255, blue: 2/255, alpha: 1)

关于ios - MGLPolyLine 颜色更改不起作用 - Swift 4、Mapbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54610042/

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