【发布时间】:2019-04-13 06:27:42
【问题描述】:
【问题讨论】:
标签: ios objective-c uiviewanimation
【问题讨论】:
标签: ios objective-c uiviewanimation
首先,一个好的问题应该包含您的代码或显示您遇到的问题的简化示例代码。 gif 有助于显示您所看到的内容,但如果没有代码的上下文,您将获得否决票并收到更少的答案(另外,您收到的答案主要是推测/假设,就像我的即将是)。
我猜你看到的是动画开始和结束附近视图不透明度的变化,所以“当屏幕变黑时”你看到的是背景窗口。虽然它可能并不完美,但快速解决方法是更改窗口的背景颜色以匹配目标视图控制器的背景颜色(然后在转换完成后根据需要将其设置回来)。
// within your perform method for the transition
// hold onto the previous window background color
UIColor *previousWindowBackgroundColor = sourceViewController.view.window.backgroundColor;
// switch the window background color to match the destinationController's background color temporarily
sourceViewController.view.window.backgroundColor = destinationController.view.backgroundColor;
...
// perform the transition
// switch the window color back after the transition duration from above
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(animationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// make sure we still have a handle on the destination controller
if (destinationController) {
destinationController.view.window.backgroundColor = previousWindowBackgroundColor;
}
});
通过创建您自己的动画师来使用自定义动画过渡工作流程,如我在此处的回答中所述:https://stackoverflow.com/a/52396398/7833793
答案显示了一个用于上/下滑动动画的自定义动画器,但它应该让您清楚地了解如何为交叉淡入淡出做这件事。
【讨论】: