Using SwiftUI in a playground
You can totally start learning and experimenting with SwiftUI in an Xcode playground. Just import PlaygroundSupport
, and assign a UIHostingController
as your live view:
1
2
3
4
5
6
7
8
9
10
11
import SwiftUI
import PlaygroundSupport
struct MyView: View {
var body: some View {
Text("Hello, world!")
}
}
let vc = UIHostingController(rootView: MyView())
PlaygroundPage.current.liveView = vc
This post is licensed under CC BY 4.0 by the author.