🅿️Scene
SwiftUI ⟩ scenes ⟩ Scene (protocol)
- 管理應用程式的「起始畫面」與「顯示範圍」。 
- WindowGroup:自訂介面(可以有多個視窗) 
- DocumentGroup:自動處理文件開啟、儲存、關閉等功能 
- SettingsScene:建立應用程式的設定介面(主要用於 macOS) 
import SwiftUI
@main
struct MyApp: App {
    // ⭐️  `App` protocol requirement
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}📁 custom scene
struct MyScene: Scene {
    // ⭐️  `Scene` protocol requirement
    var body: some Scene {
        WindowGroup {
            MyRootView()
        }
    }
}Last updated
Was this helpful?