开发者

Automatically scaling UIView and all contents on rotation

This should be simple but it just eludes me now.

I have an app in portrait mode, and when tilting the device into landscape mode, I just want all of the content to aspect scale down so that all content is displayed in the center of the screen, which would cause empty space on the left and right sides (this is fine). How do I set this up in Interface Builder? I have one containing UIView 开发者_运维技巧and am hoping that by having that one properly resized, all of the UIImageViews etc should also be aspect scaled down.

Automatically scaling UIView and all contents on rotation


So this is the answer from Rincewind over at Apple's forums... it worked out for me. I had to work on the contentMode and autoscaling parameters properly for all subviews of the top view, which I resized (changed its frame) when orientation changes.

You should set the contentMode of your UIView to UIViewContentModeScaleAspectFit. You can configure this in Interface Builder via the ContentMode popup. Keep in mind that by setting this your view will not redraw without you calling -setNeedsDisplay manually. Keep in mind that if your view starts small and grows that it will simply zoom your small content until you redraw the view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜