![](/img/trans.png)
[英]presentModalViewController - ViewController automatically disappears after presenting
[英]Blur viewcontroller darkens after presenting
在像這樣推動視圖控制器之后:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.