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 right 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:
button.layer.cornerRadius = button.frame.width / 2;
button.layer.masksToBounds = Yes;
Hope someone can help me to understand how to prevent from clipping.
Thanks!