title: How to create a circular UIImageView
body: <p>I am having issue creating a circular <code>UIImageView</code>. If I were to manually set the <code>corderRadius</code> to a value, eg. 50, it will have rounded corner. But when I try to set it as half of the frame's height or width (<code>frame.width / 2</code> or <code>frame.height / 2</code>), it doesn't work. Somehow, the frame is <code>(0, 0, 0, 0)</code> when I try to print it.</p>
  
  <p>And here is my code,</p>
  
  <pre><code>import UIKit
  
  class TestIconController : UIViewController {
  
  let icon: UIImageView = {
      let imageView = UIImageView()
      imageView.layer.cornerRadius = imageView.frame.width / 2
      imageView.clipsToBounds = true
      imageView.layer.masksToBounds = true
      imageView.backgroundColor = .red
      imageView.translatesAutoresizingMaskIntoConstraints = false
      return imageView
  }()
  
  override func viewDidLoad() {
      super.viewDidLoad()
      loadLogo()
  }
  
  func loadLogo() {
      view.addSubview(icon)
  
      // Constraints
      icon.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      icon.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
      icon.heightAnchor.constraint(equalToConstant: 200).isActive = true
      icon.widthAnchor.constraint(equalToConstant: 200).isActive = true
    }
  
  }
  </code></pre>