我正在使用来自我的 Root View Controller 的转换委托(delegate)模态呈现一个 View Controller 。
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIViewController *rootVC = [window rootViewController];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:authVC];
navController.modalPresentationStyle = UIModalPresentationCustom;
navController.navigationBar.translucent = NO;
navController.transitioningDelegate = self;
[rootVC presentViewController:navController animated:YES completion:nil];
我的过渡委托(delegate)添加如下 View ,其中
authorizationVC
是截图中的登录 View 。UIView *containerView = [transitionContext containerView];
[containerView addSubview:blurredView];
[containerView insertSubview:_authorizationVC.view aboveSubview:blurredView];
_authorizationVC.view.frame = CGRectMake(10, 30, 300, 450);
起初, View 动画,导航栏是全高的,我认为是 64 像素(导航栏为 44,状态栏为 20)。
一旦我的动画完成,导航栏就会缩小到 44 像素。这种转变令人不安。我的 View Controller 中的内容不受影响。
如何避免这个抖动的导航栏?第二张图片是我想要实现的。
最佳答案
在将 View 添加到其父 View 之前设置 View 的所有属性。
UIView *containerView = [transitionContext containerView];
_authorizationVC.view.frame = CGRectMake(10, 30, 300, 450); /// Change the frame FIRST!
[containerView addSubview:blurredView];
[containerView insertSubview:_authorizationVC.view aboveSubview:blurredView];
瞧!导航栏按预期工作。
关于ios - 自定义 View Controller 展示导致导航栏弹跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23353159/