Subview displaying outside the bounds of the parent UIView Subview displaying outside the bounds of the parent UIView ios ios

Subview displaying outside the bounds of the parent UIView


If you're setting up your views in code, set the clipsToBounds property of the superview to YES.

If you're setting up your views in a nib, turn on the “Clip Subviews” checkbox on the superview. It's off by default, as in this screenshot:

Clip Subviews checkbox


Programmatically

[YourSuperview setClipsToBounds:YES]