模糊viewcontroller在呈现后变暗

时间:2015-01-16 02:20:44

标签: ios objective-c

我按下我的视图控制器之后:

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];
}

1 个答案:

答案 0 :(得分:1)

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