UINavigationController 覆盖从右到左的推送显示黑色背景
Posted
技术标签:
【中文标题】UINavigationController 覆盖从右到左的推送显示黑色背景【英文标题】:UINavigationController override push from Right to Left showing black background 【发布时间】:2014-06-29 13:14:33 【问题描述】:有谁知道为什么在覆盖 push 或 pop to right to left 时它会在 push it self 后面显示这条黑色褪色线?
附上显示问题的图片:
这是我用来推送的:
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
[super pushViewController:viewController animated:NO];
if (animated)
CATransition *transition = [CATransition animation];
transition.duration = TRANSITION_DURATION;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.layer addAnimation:transition forKey:nil];
这是给流行音乐的:
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
if (animated)
CATransition *transition = [CATransition animation];
transition.duration = TRANSITION_DURATION;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.layer addAnimation:transition forKey:nil];
return [super popViewControllerAnimated:NO];
【问题讨论】:
嘿伙计们,这里仍然没有答案..请帮助某人。 我觉得对你有帮助:***.com/questions/6433385/… 【参考方案1】:而不是 [self.view.layer addAnimation:transition forKey:nil] 你应该写 [self.navigationController.view.layer addAnimation:transition forKey:kCATransition];
【讨论】:
【参考方案2】:我在一些视图控制器中设置了"self.view.translatesAutoresizingMaskIntoConstraints = NO;"
。删除此行修复了不规则动画和黑屏问题。
【讨论】:
以上是关于UINavigationController 覆盖从右到左的推送显示黑色背景的主要内容,如果未能解决你的问题,请参考以下文章
UINavigationController 覆盖从右到左的推送显示黑色背景
捕捉 UINavigationController 本机后退按钮操作
使用 UINavigationController 自动旋转
UINavigationBar 和 UINavigationController 的内容之间的差距