iOS判断横竖屏

2017-06-07  本文已影响1623人  fangzhiyuan
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    NSLog(@"UIViewController will rotate to Orientation: %ld", toInterfaceOrientation);

    if(([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)){//横屏
        NSLog(@"横屏");
        self.pyTrendChart.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);

    }else{//竖屏
        NSLog(@"竖屏");
        self.pyTrendChart.frame = CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 280);
    }
}

自己放在简书里记录一下,同时也方便别人.

上一篇 下一篇

猜你喜欢

热点阅读