iOS alertVC 横屏推出,并将其优先级设为最高

2021-08-09  本文已影响0人  今年27

推出一个自定义的alertVC

我们需要将设置
alertVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;

LandscapeViewController

- (BOOL)shouldAutorotate{
    return NO;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeRight;
}

-(UIInterfaceOrientationMask)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeRight;
}

    LandscapeViewController* alertVC = [LandscapeViewController new];
    alertVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    UIWindow* alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    alertWindow.rootViewController = [LandscapeViewController new];
    alertWindow.windowLevel = UIWindowLevelAlert + 1;
    [alertWindow makeKeyAndVisible];
    CGAffineTransform rotation = CGAffineTransformMakeRotation(M_PI_2);
    [alertWindow setTransform:rotation];
    alertWindow.frame = CGRectMake(0, 0, alertWindow.frame.size.width, alertWindow.frame.size.height);
    self.alertWindow = alertWindow;
    [alertWindow.rootViewController presentViewController:alertVC animated:NO completion:nil];
上一篇 下一篇

猜你喜欢

热点阅读