我有一个侧面导航控制器并通过 UIButton 呈现它。当我直接将此 NC 设为根视图控制器时[self presentviewcontroller: NC animated: YES completion: nil]
,由于某种原因,NC 的菜单侧被UITransitionView
我不能消失。
我已经尝试过以下方法:
UIWindow *window = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
window.backgroundColor = kmain;
CATransition* transition = [CATransition animation];
transition.duration = .5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromTop;
[nc.view.layer addAnimation:transition forKey:kCATransition];
[UIView transitionWithView:window
duration:0.5
options:UIViewAnimationOptionTransitionNone
animations:^{ window.rootViewController = nc; }
completion:^(BOOL finished) {
for (UIView *subview in window.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UITransitionView")]) {
[subview removeFromSuperview];
}
}
}];
但它非常hacky,并且随着窗口的rootviewcontroller在过渡过程中发生变化,它有点不稳定,导航控制器的一部分和右上角变黑。看起来很糟糕。
通过以下方式获取点击事件UITransitionView
,设置containerView
's userInteractionEnabled
to false
。这是如果您正在使用以下方法制作自定义过渡动画UIViewControllerAnimatedTransitioning
.
例如,在你的animateTransition(_:)
:
func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
containerView.isUserInteractionEnabled = false
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)