Every view has a layer as its backing property. The relevance of masksToBounds is that it tells the layer to clip the View to its bounds.
What i read on multiple websites was a little misleading, such as:
"It depends on
In this answer by sublayers this guy also means the VIEW that has the layer as its property. So when you set the cornerRadius of the layer, the layer gets rounded but the view overshadows the layer. But when you set masksToBounds to YES, then the view gets clipped according to the layer and hence its corners also get rounded. :)
Hope this helps someone.
What i read on multiple websites was a little misleading, such as:
"It depends on
masksToBounds
which determines if the sublayers are clipped
to the receiver’s bounds
. So If YES
, an implicit mask matching the layer bounds is applied to the layer, including the effects
of the cornerRadius
property." in a StackOverflow Post.In this answer by sublayers this guy also means the VIEW that has the layer as its property. So when you set the cornerRadius of the layer, the layer gets rounded but the view overshadows the layer. But when you set masksToBounds to YES, then the view gets clipped according to the layer and hence its corners also get rounded. :)
Hope this helps someone.