LoginSignup
0
1

More than 1 year has passed since last update.

【SwiftUI】外観モードを検知する

Last updated at Posted at 2022-06-23

公式ドキュメント

使い方

import SwiftUI

struct ContentView: View {
    @Environment(\.colorScheme) var colorScheme
    var body: some View {
        Text(colorScheme == .dark ? "Dark" : "Light")
    }
}

おわり

システムのカラースキームとは別のカラースキームをアプリ内で使用したい場合は少し工夫が必要になります。
以下の記事がとても参考になりました。

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