I have three buttons. One button whose properties are changed by a custom subclass. Another one being an IBOutlet and another one being an instance of UIButton.
Now, why do I need to set masksToBounds/clipsToBounds to true in subclass to change its corner radius but don’t need to mention it in viewDidLoad?
You need to use the UIView class clipsToBounds property in order to make sure that the custom button isn’t drawn over the corner radius. This isn’t necessary for standard ones since they actually behave like that by default and out of the box.
Very well. Now this brings me to my next question - how does shadow work in both the cases?
For the custom button when I try to add shadows, it gets removed because clipsToBounds is set to true, but in case of ViewController it just works fine. How is that happening?