views:

903

answers:

2

Hi guys.

Is it possible to have an UIView with its bounds size different of its frame size?

I'm trying to create an UIView with "{{0,0},{320,367}}" frame and "{{0,15},{320,337}}" bounds but i can't get it done using setBounds() and setFrame().

I got from the doc that changing bounds or frame changes frame or bounds accordingly but i thought it was OK to have different values for theses.

Thanks a lot.

+1  A: 

Typically:
1. The bounds is at (0,0) while the frame (and center) give the view's position.
2. The bounds and frame would have the same width and height.

UPDATE
It sounds like you want to add a button below a specific view that was previously larger.
In this case, I would create a new view that occupies the full space. Then, I would add the now smaller specific view in the desired position as a subview. Finally, I would add the new button in the desired position as another subview to the new full space view.
You can do this layout in Interface Builder or code.

gerry3
I'm trying to resize a view in order to have a blank space beneath it. Since i want to add a button in this blank space, i would like the view to get resized modifying the bounds but with the original frame size so my button is touchable.
Vivi
My answer has been updated with a suggested layout.
gerry3
Vivi
+1  A: 

Yes, when the device is rotated, your entire view hierarchy is transform'd using a CGAffineTransform. In this case, your bounds and frames may have different values. The best way to assure position of a view is to set its bounds property for the size, and its center property for the position.

Ben Gottlieb