How do you create an iOS liveView in Xcode 8/Swift 3 [duplicate]

跟風遠走 提交于 2019-12-13 13:12:33

问题


I can't figure out how to create and display a live view in an Xcode 8/Swift 3 Playground. If Apple has comprehensive documentation on playgrounds and live views, I can't find it, and all my searching online reveals either tutorials on Xcode 7 or the new iPad playgrounds. The few examples I have found set up Mac OS views, which is not what I want (I work mostly in iOS, so the code I want to test out is iOS code, dealing with iOS view hierarchies.)

Can somebody give me the bare minimum setup to create a live view and install views into it from an Xcode 8 playground?

Then, can somebody point me to some good documentation on playgrounds, and how you configure and use them?


回答1:


It works like this:

import UIKit
import PlaygroundSupport

let view = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
view.backgroundColor = UIColor.red

PlaygroundPage.current.liveView = view

Unfortunately I'm not aware of a good documentation. But I believe there is a book by Erica Sadun about Playgrounds.



来源:https://stackoverflow.com/questions/40449795/how-do-you-create-an-ios-liveview-in-xcode-8-swift-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!