在像这样推动视图控制器之后:

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:^{

    }];


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

- (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;

 }


移动[self blurBackground];在viewWillAppear

关于ios - 呈现后模糊Viewcontroller变暗,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27976344/

10-11 14:51