Mix color using hex values in SwiftUI, UIKit and AppKit.
Targets iOS/iPadOS/tvOS 14, watchOS 7 and macOS 11 Big Sur. Written in Swift 5.6 and requires Xcode 13.3 or newer to build.
import SwiftUI
import Hex
let _: [Color] = [
Color(hex: "FFFFFF"),
Color(hex: "#ccc", opacity: 0.9),
Color(hex: 0x0000CC)
]
Plus, get the hex value of any color constructed from HSB, RGB or hex values:
print(Color(red: 0.0, green: 0.0, blue: 0.8).hex) // 0x0000CC
print(Color(white: 0.8).hexString) // "#CCCCCC"