title: self.view = mainView vs self.view.addSubview(mainView) with respect to corner radius
body: <p>I have a UIView in which I have a circular border around it. Here is the code for it:</p>
  
  <pre><code>let v = UIView()
  
  self.view.addSubview(v)
  v.backgroundColor = .orange
  
  v.translatesAutoresizingMaskIntoConstraints = false
  v.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
  v.rightAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true
  v.topAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
  v.heightAnchor.constraint(equalTo: v.widthAnchor).isActive = true
  
  self.view.layoutIfNeeded()
  v.layer.cornerRadius = v.frame.width / 2
  </code></pre>
  
  <p>If I set the ViewController view like this: <code>self.view = mainView</code> (mainView is a subclass of MainView which contains some other subviews), then the result of the corner radius is no longer a circle: <a href="https://i.stack.imgur.com/OyswM.png" rel="nofollow noreferrer">Resulting "circle"</a>.</p>
  
  <p>However, if I use <code>self.view.addSubview(mainView)</code> (and add autolayout constraints to mainView) and replace <code>self.view.addSubview(v)</code> with <code>self.mainView.addSubview(v)</code> then the circle turns out to be fine.</p>
  
  <p>Why does the circle turn out weird only when I set <code>self.view = mainView</code>, but is fine when I do <code>self.view.addSubview(mainView)</code>?</p>