Reputation:
I can't find an updated article that shows how to show a live preview of my UIView animations. Methods like XCShowView() aren't used in Swift anymore, according to the error I received in the playground editor.
Does anyone know how to show the prototyping preview in Playgrounds?
Upvotes: 1
Views: 496
Reputation: 19641
This works in Xcode 8:
import UIKit
import PlaygroundSupport
let v = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 600, height: 600)))
v.backgroundColor = UIColor.green
PlaygroundPage.current.liveView = v
Create a playground with that code and you should see a green box on the live view.
Remember to show the "live" assistant editor. See PlaygroundSupport reference for more.
Upvotes: 1