开发者

How to set view size to match device screen in iOS?

开发者 https://www.devze.com 2023-04-05 08:56 出处:网络
I have a UIView that I need to resize to half the height of the screen, it works fine in Portrait mode but if I lunch the app with the iPad in landscape the UIView always get the screen portra开发者_S

I have a UIView that I need to resize to half the height of the screen, it works fine in Portrait mode but if I lunch the app with the iPad in landscape the UIView always get the screen portra开发者_StackOverflow中文版it size, any ideas how to get the size at launch and after change in orientation?

I try the following but always get protrait where width = 768 and height = 1024

NSLog( @"bounds: %@", NSStringFromCGRect( [UIScreen mainScreen].bounds ) );
NSLog( @"frame: %@", NSStringFromCGRect( [UIScreen mainScreen].applicationFrame ) );


Try to set property autoresizingMask of your view to UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin.

Or try to place with its value. After setting this value your view will automatically resize after device rotation.

0

精彩评论

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

关注公众号