“Cor hexadecimal swifttui” Respostas de código

Cor hexadecimal swifttui

"Color sets can be added in the Assets.xcassets of your project, which you can use throughout your views."
sirchamallow

Cor hexadecimal rápida

//https://stackoverflow.com/questions/24263007/how-to-use-hex-color-values
var color1 = hexStringToUIColor("#d3d3d3")

//Create Func
func hexStringToUIColor (hex:String) -> UIColor {
    var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased()

    if (cString.hasPrefix("#")) {
        cString.remove(at: cString.startIndex)
    }

    if ((cString.count) != 6) {
        return UIColor.gray
    }

    var rgbValue:UInt64 = 0
    Scanner(string: cString).scanHexInt64(&rgbValue)

    return UIColor(
        red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0,
        green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0,
        blue: CGFloat(rgbValue & 0x0000FF) / 255.0,
        alpha: CGFloat(1.0)
    )
}

Lucky Lapwing

Respostas semelhantes a “Cor hexadecimal swifttui”

Perguntas semelhantes a “Cor hexadecimal swifttui”

Mais respostas relacionadas para “Cor hexadecimal swifttui” em Swift

Procure respostas de código populares por idioma

Procurar outros idiomas de código