Files
swiftGrammar/AIGrammar/lib/ColorToString.swift
2024-08-12 10:49:20 +08:00

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
)
}
}