Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top