开发者

Does [[UIScreen mainScreen] bounds] return values respond to orientations?

So basically 开发者_StackOverflowmy question that. Does the bounds CGRect change with the screen orientation or is it static?

Thanks!


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

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


I created a property to return the screen bounds, taking into consideration 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;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜