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;
                
            }];
        }];
    }

posted on 2016-02-01 20:49  老吴_WZX  阅读(1215)  评论(0编辑  收藏  举报