22 lines
421 B
Swift
22 lines
421 B
Swift
//
|
|
// ColorToString.swift
|
|
// AIGrammar
|
|
//
|
|
// Created by oscar on 2024/3/28.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
extension Color {
|
|
static func hex(_ hex: UInt, alpha: Double = 1.0) -> Color {
|
|
return Color(
|
|
red: Double((hex >> 16) & 0xFF) / 255.0,
|
|
green: Double((hex >> 8) & 0xFF) / 255.0,
|
|
blue: Double(hex & 0xFF) / 255.0,
|
|
opacity: alpha
|
|
)
|
|
}
|
|
}
|
|
|