SwiftUIã§ã¯ç´æ¥UIColorã使ããã¨ãã§ãã¾ããã
å®è¡ç°å¢
- Xcode 11.6
- iOS 13.6
UIColor to Color
UIColorãSwiftUIã®Colorã«å¤æããã®ã¯ç°¡åã§ãã
let color = Color(UIColor.label)
ã·ã¹ãã ã§å®ç¾©ããã¦ããUIColorã®è²ã使ããã
Xcode 11.6æç¹ã§ä¸ä¾¿ãªã¨ããã¨ããã°ããã¨ãã° UIColor.label
ãªã©ã·ã¹ãã ã§å®ç¾©ããã¦ããè²ã使ç¨ãããã¨ãã§ãã¾ãããã
import UIKit import SwiftUI extension Color { static let label: Color = Color(UIColor.label) static let secondaryLabel: Color = Color(UIColor.secondaryLabel) static let tertiaryLabel: Color = Color(UIColor.tertiaryLabel) static let quaternaryLabel: Color = Color(UIColor.quaternaryLabel) static let systemFill: Color = Color(UIColor.systemFill) static let secondarySystemFill: Color = Color(UIColor.secondarySystemFill) static let tertiarySystemFill: Color = Color(UIColor.tertiarySystemFill) static let quaternarySystemFill: Color = Color(UIColor.quaternarySystemFill) static let systemBackground: Color = Color(UIColor.systemBackground) static let secondarySystemBackground: Color = Color(UIColor.secondarySystemBackground) static let tertiarySystemBackground: Color = Color(UIColor.tertiarySystemBackground) static let systemGroupedBackground: Color = Color(UIColor.systemGroupedBackground) static let secondarySystemGroupedBackground: Color = Color(UIColor.secondarySystemGroupedBackground) static let tertiarySystemGroupedBackground: Color = Color(UIColor.tertiarySystemGroupedBackground) static let systemRed: Color = Color(UIColor.systemRed) static let systemBlue: Color = Color(UIColor.systemBlue) static let systemPink: Color = Color(UIColor.systemPink) static let systemTeal: Color = Color(UIColor.systemTeal) static let systemGreen: Color = Color(UIColor.systemGreen) static let systemIndigo: Color = Color(UIColor.systemIndigo) static let systemOrange: Color = Color(UIColor.systemOrange) static let systemPurple: Color = Color(UIColor.systemPurple) static let systemYellow: Color = Color(UIColor.systemYellow) static let systemGray: Color = Color(UIColor.systemGray) static let systemGray2: Color = Color(UIColor.systemGray2) static let systemGray3: Color = Color(UIColor.systemGray3) static let systemGray4: Color = Color(UIColor.systemGray4) static let systemGray5: Color = Color(UIColor.systemGray5) static let systemGray6: Color = Color(UIColor.systemGray6) }