UIView hide children views when out of bounds
I think you want to enable "clip subviews" on the parent view.
The documentation says that the clipsToBounds
property of UIView will clip the drawing to the bounds, or more precisely that the subview can't draw outside of the bounds of the superview.
for more read the SO post
UIView clipsToBounds property: Does it improve performance?
Set the parent view's clipsToBounds
property to YES
.
Programmatically: view.clipsToBounds=YES;
Through interface builder: Click the view->Attributes Inspector->Check Clip to Bounds