When working on prototypes it is easy to create a new Playground to experiment on views. This makes the development really fast and easy. This method is much faster than creating a new XCode Project for prototyping.
Below is the code I use in Swift Playground
import UIKit import PlaygroundSupport let f = CGRect(x: 0.0, y: 0.0, width: 50.0, height: 50.0) let v = UIView(frame: f) v.backgroundColor = UIColor.yellow PlaygroundPage.current.liveView = v
Then, to see the live view, select View – Assistant Editor – Show Assistant Editor
And then select Timeline option to see the live view.
Later, we will add UIView with red background color as sub-view to test live updates.
// will be adding red view as sub view let redView = UIView(frame: CGRect.zero) redView.translatesAutoresizingMaskIntoConstraints = false redView.backgroundColor = UIColor.red v.addSubview(redView) redView.centerXAnchor.constraint(equalTo: v.centerXAnchor, constant: 0.0).isActive = true redView.centerYAnchor.constraint(equalTo: v.centerYAnchor, constant: 0.0).isActive = true redView.widthAnchor.constraint(equalToConstant: 15.0).isActive = true redView.heightAnchor.constraint(equalToConstant: 15.0).isActive = true
And finally, see the updates.