Does [[UIScreen mainScreen]] limit the returned values ​​to orientations?

So basically my question. Are CGRect borders changed with screen orientation or static?

Thanks!

+4
source share
2 answers

Just tested on an iPhone simulator - it always returns the same value for all orientations

{{0, 0}, {320, 480}}

+6
source

I created a property to return the borders of the screen, taking into account the orientation of the device.

- (CGRect)boundsWithRespectToOrientation { CGRect bounds = self.bounds; if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]) && bounds.size.height > bounds.size.width) bounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width); else if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]) && bounds.size.width > bounds.size.height) bounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width); return bounds; } 
-1
source

Source: https://habr.com/ru/post/1333574/


All Articles