Skip to content

Instantly share code, notes, and snippets.

@abdelrahmanTD
abdelrahmanTD / ColorExtension.swift
Last active January 3, 2022 21:35
Extension Color for converting hex codes
import SwiftUI
public extension Color {
init(hexCode: String) {
let scanner = Scanner(string: hexCode)
var rgbValue: UInt64 = 0
scanner.scanHexInt64(&rgbValue)
let r = (rgbValue & 0xff0000) >> 16
let g = (rgbValue & 0xff00) >> 8