弹出半透明控制器,同时遮盖tabBar

676 阅读1分钟

需求:在根视图上弹出一个控制器,要同时遮盖tabBar

//跳转Controller方法实现

GroupContactsController *controller = [[GroupContactsController alloc] init];

UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:controller];
//设置弹出Controller时的风格
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {

appDelegate.window.rootViewController.definesPresentationContext = YES;

nc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
//弹出导航控制器,半透明设置在 GroupContactsController 中进行设置。
[appDelegate.window.rootViewController  presentViewController:nc animated:YES completion:nil];

} else {

appDelegate.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
//弹出导航控制器,半透明设置在 GroupContactsController 中进行设置。
[appDelegate.window.rootViewController presentViewController:nc animated:YES completion:nil];

}