3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SwiftUI】ユーザーが設定している言語と地域を取得する

Posted at

はじめに

ユーザー端末の言語設定と地域設定を知る方法を紹介します。

完成

simulator_screenshot_50ADA5DE-5C9F-4DF6-9687-C735BCF70AFD.png

実装

import SwiftUI

struct ContentView: View {
    @Environment(\.locale) var locale
    var body: some View {
        VStack {
            Text("言語設定: \(locale.language.languageCode?.identifier ?? "")")
            Text("地域設定: \(locale.region?.identifier ?? "")")
        }
    }
}

おわり

特定の地域限定の機能などを実装する際に使えそうです。

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?