なるほどこうするのか。
iOS ↔ macOS と切り替えると、
ビルドで落ちて萎えるときの
一つの何かのきっかけに。
最新の SwiftUI ならシンプルです。
import SwiftUI
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
}
👉 ios - SwiftUI: Get the Dynamic Background Color (Dark Mode or Light Mode) - Stack Overflow 


マルチなプラットフォーム作成時には、押さえておきたい記述です。
【SwiftUI】NavigationSplitView と TabView の切り替え判定 🔀
👉 https://t.co/DRqw13upS9#SwiftUI #Swift pic.twitter.com/6mX8EtrbCS— chanzmao (@maochanz) December 15, 2023
 
 
		 
           
          

