Snippets Collections
    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)
        )
    }
star

Wed May 31 2023 11:24:13 GMT+0000 (Coordinated Universal Time) https://www.plurance.com/hybrid-crypto-exchange-development

#hybridcryptoexchange development services #hybridexchangedevelopment #hex #hybridexchange
star

Fri May 13 2022 10:33:12 GMT+0000 (Coordinated Universal Time)

#ios #swift #color #colour #hex

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension