在Xcode 11 Playground中使用SwiftUI

埃文·C

我知道如何在常规应用程序项目的Xcode 11中使用SwiftUI,但是我想知道是否有一种方法可以在操场上使用它,即使我不能使用实时编辑器也是如此?

安德烈·卡雷拉(Andre Carrera)

当然,这很简单:

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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章