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; }
source share