なるほど、こうするといいのか。
public extension Color {
#if os(macOS)
static let background = Color(NSColor.windowBackgroundColor)
static let secondaryBackground = Color(NSColor.underPageBackgroundColor)
static let tertiaryBackground = Color(NSColor.controlBackgroundColor)
#else
static let background = Color(UIColor.systemBackground)
static let secondaryBackground = Color(UIColor.secondarySystemBackground)
static let tertiaryBackground = Color(UIColor.tertiarySystemBackground)
#endif
}
基本的ですが、いろいろ使えそうです。
🙆🏻♂️ 参考
【SwiftUI】iOS と macOS で互換したいコードの一つの解法
— chanzmao (@maochanz) May 23, 2024
👉 https://t.co/gUgv9B40x7#プログラミング #SwiftUI