title: How to prevent from clipping the subviews when I set the cornerRadius of a UIView?
body: <p>I am trying to set the cornerRadius of a subclass view of UIButton, the round corner shows in a right way, but when I try to add a subView(the flower icon) on it, the subview seems to be clipped like the picture on the <strong>right</strong> side below, this is not what I expected. I try to make the correct appearance like the picture shows on the left side, the icon not be clipped. The code I use:    </p>
  
  <pre><code>button.layer.cornerRadius = button.frame.width / 2;
  button.layer.masksToBounds = Yes;    
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/KyyG7.png" alt="Avatar View(left)">
  <img src="https://i.stack.imgur.com/btKGe.png" alt="Avatar View(right)"></p>
  
  <p>Hope someone can help me to understand how to prevent from clipping.<br>
  Thanks!</p>