UIView hide children views when out of bounds

I have a view, lets say 100x100. And it has set of uiviews as subviews: let say 30x30

If a subview has top-left coordinate: (90,90) - I expect to see only part of this subview. But I still see entire area - even if it is out of parents bounds

The question is how to make uiview to show only those parts of subview, which are in original bounds?

thank you

Answers


Set view's clipsToBounds property to YES.

Programmatically: view.clipsToBounds=YES;

Through interface builder: Click the view->Attributes Inspector->Check Clip subviews


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?


Indeed, from the storyboard, tick the parent UIView's "Clip Subviews" checkbox. This is how it worked for me.


Need Your Help

Java version automatically change to java 1.5 after maven update

java eclipse maven

I am using eclipse as IDE. When I right click on the project and then click maven update my java version change to 1.5. Here is what I did so far, I followed all the steps listed here

SQLAlchemy - Writing a hybrid method for child count

python sqlalchemy flask

I'm using Flask-SQLAlchemy, and I'm trying to write a hybrid method in a parent model that returns the number of children it has, so I can use it for filtering, sorting, etc. Here's some stripped d...