title: Custom UIImageView Class that adds shadow and make image round in Swift 3
body: <p>I'm trying to create a custom UIImageView class that accomplishes two things, it makes the image view round and add a shadow to it.</p>
  
  <p>This is what i have:</p>
  
  <p><strong>RoundImage.swift</strong></p>
  
  <pre><code>class RoundImage: UIImageView {
       override func awakeFromNib() {
  
        }
  
  
        func setImageAndShadow(image: UIImage) {
          self.image = image
          self.superview?.layoutIfNeeded()
          print("Image size \(self.frame.size)")
          self.clipsToBounds = true
          layer.masksToBounds = true
          layer.cornerRadius = self.frame.height / 2
          layer.shadowOffset = CGSize(width: 0, height: 3.0)
          layer.shadowColor = UIColor.black.cgColor
          layer.shadowOpacity = 0.7
          layer.shadowRadius = 4
  
      }
  
  } 
  </code></pre>
  
  <p><strong>ViewController.Swift</strong></p>
  
  <pre><code>Class ViewController : UIViewController {
     @IBOutlet weak var userImageView: RoundImage!
  
  
     override func viewDidLoad() {
        self.userImageView.setImageAndShadow(image: User.sharedInstance.profileImage!)
     }
  
  }
  </code></pre>
  
  <p>As a result of this a get a round image in the app, but there's no shadow in it.</p>
  
  <p>Thanks in advance for any help.</p>