Using SwiftUI in a playground
Discover page available: SwiftUIYou can totally start learning and experimenting with SwiftUI in an Xcode playground. Just import PlaygroundSupport
, and assign a UIHostingController
as your live view:
import SwiftUI
import PlaygroundSupport
struct MyView: View {
var body: some View {
Text("Hello, world!")
}
}
let vc = UIHostingController(rootView: MyView())
PlaygroundPage.current.liveView = vc