Pular para o conteúdo
Skip

ScenePhase

Este conteúdo não está disponível em sua língua ainda.

Skip support for SwiftUI.ScenePhase.

The following example screens and source code is from SkipUI’s Showcase sample app ScenePhasePlayground.swift

import SwiftUI
struct ScenePhasePlayground: View {
@Environment(\.scenePhase) var scenePhase
@State var history: [ScenePhase] = []
var body: some View {
List {
Section("ScenePhase history") {
ForEach(Array(history.enumerated()), id: \.offset) { phase in
Text(verbatim: String(describing: phase.element))
}
}
}
.onChange(of: scenePhase) { phase in
logger.log("onChange(of: schenePhase): \(String(describing: phase))")
history.append(phase)
}
.toolbar {
PlaygroundSourceLink(file: "ScenePhasePlayground.swift")
}
}
}