1.iOS8之后只需要设置一个最新的属性
SecondViewController *secondVC = [[SecondViewController alloc] init];
secondVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
//self.tabBarController.tabBar.hidden = YES; 当presentingVC有根视图控制器tabBarController,隐藏tabBar
secondVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:.14];
[self presentViewController:secondVC animated:YES completion:^{
}];
如果当presentingVC有根视图控制器tabBarController,上面的设置会使tabBar未被覆盖,意思就好像是你有一直看到presentingVC直接导致不会走viewWiillAppear,不能在原视图即将出现时把隐藏tabBar的属性改回来。
2.在SecondViewController设置
- (void)viewDidLoad {
[super viewDidLoad];
//模糊视图
UIBlurEffect *beffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
UIVisualEffectView *visualEffect = [[UIVisualEffectView alloc]initWithEffect:beffect];
visualEffect.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
visualEffect.alpha = 0.7;
[self.view addSubview:visualEffect];
}
- (void)viewWillDisappear:(BOOL)animated
{
self.presentingViewController.tabBarController.tabBar.hidden = NO;
}