我知道如何在常规应用程序项目的Xcode 11中使用SwiftUI,但是我想知道是否有一种方法可以在操场上使用它,即使我不能使用实时编辑器也是如此?
当然,这很简单:
import PlaygroundSupport
PlaygroundPage.current.liveView = UIHostingController(rootView: PlaygroundRootView())
public struct PlaygroundRootView: View {
public init() {}
public var body: some View {
Text("Hello World!")
}
}
在此处查看更多信息:https : //github.com/attoPascal/SwiftUI-Tutorial-Playground
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句