Skip to content

Instantly share code, notes, and snippets.

@khirotaka
Last active October 10, 2019 00:29
Show Gist options
  • Save khirotaka/a0acf5c4f797205704557b09b107ec6b to your computer and use it in GitHub Desktop.
Save khirotaka/a0acf5c4f797205704557b09b107ec6b to your computer and use it in GitHub Desktop.
import SwiftUI
import PlaygroundSupport
/*:
# Example of SwiftUI Page Transition
Run on Swift Playground (iPad)
nest is too deep...
*/
struct ContentView: View {
@State private var pushed: Bool = false
var body: some View {
VStack {
if self.pushed {
VStack {
SecondView().padding(10)
Button(action: {
self.pushed = false
}) {
Text("Back")
}
}
}
else {
VStack {
FirstView().padding(10)
Button(action: {
self.pushed = true
}) {
Text("Change")
}
}
}
}
}
}
struct FirstView: View {
var body: some View {
Text("FIRST")
}
}
struct SecondView: View {
var body: some View {
Text("SECOND")
}
}
PlaygroundPage.current.liveView =
UIHostingController(rootView: ContentView())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment