xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

SwiftUI App Dark Mode All In One

SwiftUI App Dark Mode All In One

info.plist

配置文件

Appearance: Dark

.preferredColorScheme(.dark)

PreviewProvider


//
//  ContentView.swift
//  PlacesOfInterest
//
//  Created by xgqfrms on 2022/5/19.
//

import SwiftUI

struct ContentView: View {
  var body: some View {
    TabView {
      PreviewView()
        .tabItem {
          Image(systemName: "square.grid.2x2")
          Text("风景概览")
        }
      VideoListView()
        .tabItem {
          Image(systemName: "play.rectangle")
          Text("风景视频")
        }
      MapListView()
        .tabItem {
          Image(systemName: "map")
          Text("风景地图")
        }
      ImageListView()
        .tabItem {
          Image(systemName: "photo")
          Text("风景照片")
        }
    }
  }
}

struct ContentView_Previews: PreviewProvider {
  static var previews: some View {
    ContentView()
      .preferredColorScheme(.dark)
      // .preferredColorScheme(isDarkMode ? .dark : .light)
  }
}


iOS Simulator

Dark Appearance

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-06-02 22:33  xgqfrms  阅读(104)  评论(1编辑  收藏  举报