美文网首页
iOS 部分界面强制横屏与强制竖屏

iOS 部分界面强制横屏与强制竖屏

作者: CCSHCoder | 来源:发表于2016-05-03 14:26 被阅读1778次

    最新屏幕强制旋转详见

    强制横屏(此方法为旋转视图)

    
    - (void)loadView{
        
        self.view = [[UIView alloc]init];
        
        CGRect frame = [UIScreen mainScreen].bounds;
        
        AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
        
        UIDeviceOrientation duration = [[UIDevice currentDevice]orientation];
        
        if (duration == UIDeviceOrientationLandscapeLeft) {
            
            app.window.transform = CGAffineTransformMakeRotation(M_PI*0.5);
            
            [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:YES];
            
        }else{
            
            app.window.transform = CGAffineTransformMakeRotation(M_PI*1.5);
            
            [[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeRight animated:YES];
            
        }
        
        app.window.bounds = CGRectMake(0, 0, frame.size.height, frame.size.width);
    
    }
    
    

    恢复竖屏

        app.window.transform = CGAffineTransformIdentity;
    

    相关文章

      网友评论

          本文标题:iOS 部分界面强制横屏与强制竖屏

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