0
1

【SwiftUI】iOS ↔ macOS 互換の記述

Last updated at Posted at 2024-05-23

なるほど、こうするといいのか。

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
}

sc 2024-05-23 at 13.33.22.png

sc 2024-05-23 at 13.33.36.png

基本的ですが、いろいろ使えそうです。

🙆🏻‍♂️ 参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1