【iOS】 弹出模态透明的ViewController

    ViewController *vcObj = [[ViewController alloc] initWithNibName:NSStringFromClass([ViewController class]) bundle:nil];
    UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:vcObj];
    
    if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
        
        navCon.providesPresentationContextTransitionStyle = YES;
        navCon.definesPresentationContext = YES;
        navCon.modalPresentationStyle = UIModalPresentationOverCurrentContext;
        
        [self presentViewController:navCon animated:NO completion:nil];
    }
    else {
        
        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        [self presentViewController:navCon animated:NO completion:^{
            [navCon dismissViewControllerAnimated:NO completion:^{
                appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
                [self presentViewController:navCon animated:NO completion:nil];
                appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
                
            }];
        }];
    }

你可能感兴趣的:(【iOS】 弹出模态透明的ViewController)