swift-playground - 在 Xcode 11 Playground 中使用 SwiftUI
问题描述
我知道如何在常规应用程序项目中使用 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
推荐阅读
- android - Android HILT SingletonComponent vs GoF Singleton 实例设计模式
- python - 如何修补 com_google_protobuf/python/google/__init__.py?
- emacs - 如何使命令 paredit-forward 在邪恶模式下按预期工作?
- nestjs - NestJS:无法为拥有接口的子模块提供实例
- javascript - protractor-jasmine2-screenshot-reporter 空白截图
- arrays - Yacc 不接受有效输入
- bash - 使用 iconv 解码包含希伯来字符和德语 eszett 的文件
- unity3d - 统一获取输入字段值然后 Debug.Log ing
- c++ - MFC MDI 收集“应用”按钮例程的控制状态
- angular - 打字稿:有没有办法禁用测试文件的所有语法检查?