Created
December 24, 2023 06:01
-
-
Save lucaswkuipers/4169504605d9fde4f373352614351e6e to your computer and use it in GitHub Desktop.
Color from Hex literal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension Color: ExpressibleByIntegerLiteral { | |
public init(integerLiteral value: UInt32) { | |
let red = Double((value & 0xFF0000) >> 16) / 255 | |
let green = Double((value & 0x00FF00) >> 8) / 255 | |
let blue = Double(value & 0x0000FF) / 255 | |
self.init(red: red, green: green, blue: blue) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment