Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subview displaying outside the bounds of the parent UIView

I have a UIView that contain another subview. The subview's frame is outside of the bounds of the super view. But the entire subview is visible in when I run the application. Example:

++++++++++++++++++++++++++++ +                          + +       Super view         + +                          + +                          + +     --------------------------                     +     -  Subview           +   -                      +     -                    +   -                      +     --------------------------                     +                          + +                          + ++++++++++++++++++++++++++++ 

Should be:

++++++++++++++++++++++++++++ +                          + +       Super view         + +                          + +                          + +     ---------------------+                   +     -  Subview           +                        +     -                    +                      +     ---------------------+                    +                          + +                          + ++++++++++++++++++++++++++++ 

Any idea?

like image 754
mLamaa Avatar asked Oct 22 '12 17:10

mLamaa


1 Answers

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

like image 97
rob mayoff Avatar answered Oct 05 '22 21:10

rob mayoff