So let’s say I have a UIView that in its standard configuration spans the full width and height of its container. For the purposes of this question, let’s say that its dimensions are 320×400. Suppose that this view contains content that may be (and typically is) larger than its standard dimensions (so it scrolls through content).
Now if this UIView has a UIRotationGestureRecognizer associated with it that is used to rotate the view using its transform property, how do I ensure that its frame size/drawable area is always sufficiently large for its current orientation (by “sufficiently large” I mean that the rendered content should always extend out to the original bounds, and not be clipped prior to reaching the edge of the original bounds)? For instance, if I rotate it 90 degrees the view needs to understand that its “width” may now consume up to 400 pixels, while its height is constrained to 320 pixels.
Note that I don’t want to scale the view as part of the rotation operation. Any “additional” space that becomes available due to the current rotation should be used to display additional content, if available, and not to simply display the same content at a higher zoom level.
You don’t want any empty spaces to appear when rotating. The solution is to have a subview containing a background which is sufficiently large enough to cover the entire viewport during rotation. I’d say a 400 by 400 view should do. This view can either be the parent of your contentview, but that’ll give you a bit of a positioning hassle.
Easier would be to add a subview on your currentview. Put the (large) background on this subview, make sure this view is at the bottom of the view stack and on your currentview put clipsToBounds=NO.
Beware though that disabling clipping can have a performance impact especially if your view hierarchy becomes complex.