iOS 模态跳转推出透明背景方法

1. OS >= iOS 8.0

FZLoginViewController *fzLoginViewController = [[FZLoginViewController alloc] init];
fzLoginViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:fzLoginViewController animated:NO completion:nil];

2. 若系统需兼容7.0 需要加处理

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
    controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    [self presentViewController:controller animated:YES completion:nil];
} else {
    self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentViewController:controller animated:NO completion:nil];
    self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
}

附:我的博客地址

你可能感兴趣的:(iOS 模态跳转推出透明背景方法)