title: How to apply autolayout constraints in a playground?
body: <p>I want to work with Autolayout inside an Xcode playground, however I can't get a simple setup to work.</p>
  
  <pre><code>let red = UIView(frame: CGRect.zero)
  red.backgroundColor = .red
  red.translatesAutoresizingMaskIntoConstraints = false
  
  let widthConstraint = NSLayoutConstraint(item: red, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 100)
  let heightConstraint = NSLayoutConstraint(item: red, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: 100)
  
  red.addConstraints([widthConstraint, heightConstraint])
  </code></pre>
  
  <p>However, when checking <code>red</code> after these lines have been executed, it still has a frame of <code>CGRect.zero</code> and <code>width</code> and <code>height</code> did not get updated.  </p>
  
  <p><a href="https://i.stack.imgur.com/iaNms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iaNms.png" alt="enter image description here"></a></p>