https://www.raywenderlich.com/1039-scanner-tutorial-for-macos



cell.backgroundColor = UIColor(hexColor: "9d9d9d")





extension UIColor {

        convenience init(hexColor: String) {

        let scannHex = Scanner(string: hexColor)

        var rgbValue: UInt64 = 0

        scannHex.scanLocation = 0

        scannHex.scanHexInt64(&rgbValue)

        let r = (rgbValue & 0xff0000) >> 16

        let g = (rgbValue & 0xff00) >> 8

        let b = rgbValue & 0xff

        self.init(

            red: CGFloat(r) / 0xff,

            green: CGFloat(g) / 0xff,

            blue: CGFloat(b) / 0xff, alpha: 1

        )

    }

}

+ Recent posts