美文网首页
iOS判断横竖屏

iOS判断横竖屏

作者: fangzhiyuan | 来源:发表于2017-06-07 10:34 被阅读1623次
- (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);
    }
}

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

相关文章

网友评论

      本文标题:iOS判断横竖屏

      本文链接:https://www.haomeiwen.com/subject/qyyofxtx.html