模糊视图控制器在演示后变暗



在我这样推送我的视图控制器之后:

self.takeoverViewController = [[NoNetworkViewController alloc]initWithNibName:@"NoNetworkViewController" bundle:nil];
    self.takeoverViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
    //find topmost VC and put inside a nav controller
    UIViewController *topViewController = [self getTopMostViewController];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self.takeoverViewController];
    //present the nav controller
    [topViewController presentViewController:nav animated:true completion:^{
    }];

模糊视图变暗。也就是说,我看到光线模糊了一瞬间,然后一切都变暗了。以下是我设置模糊视图的方法。

- (void)viewDidLoad {
    [super viewDidLoad];
    [self blurBackground];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //hide nav bar
    self.originalNavigationBarState = self.navigationController.navigationBar.hidden;
    self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    //show nav bar
    self.navigationController.navigationBar.hidden = self.originalNavigationBarState;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UI Utils
- (void)blurBackground {
    self.view.backgroundColor = [UIColor clearColor];
    UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView *blurView = [[UIVisualEffectView alloc]initWithEffect:effect];
    blurView.frame = self.view.bounds;
    [self.view insertSubview:blurView atIndex:0];
}
- (void)viewDidLoad {
   [super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated {
   [super viewWillAppear:animated];
   [self blurBackground];
//hide nav bar
self.originalNavigationBarState = self.navigationController.navigationBar.hidden;
self.navigationController.navigationBar.hidden = YES;
 }

移动 [自我模糊背景];在视图中将出现

最新更新