我尝试将自定义转换添加到具有xib的UIViewController。我尝试了一些方法,但它们都有相同的问题,视图显示错误的屏幕大小。
我当前的示例基于以下教程:Custom UIViewController transition in iOS with Swift
我没有对TransitionDelegate或Animators进行任何更改。
这里是xib和模拟器中的视图:
白色UIView设置为居中,宽度为80%,比例为1:1。
使用以下内容加载我的UIViewController:
let thirdViewController = ThirdViewController()
thirdViewController.transitioningDelegate = viewTransitionDelegate
thirdViewController.modalPresentationStyle = .custom
navigationController?.present(thirdViewController, animated: true, completion: nil)
如果我注释掉设置委托,视图将完全加载100%:
最后,我有另一个没有xib的UIViewController,并且以编程方式设置约束。此视图加载了相同的转换并完美加载:
我需要更改哪些内容才能使用XIB?
答案 0 :(得分:1)
我花了很多年的时间寻找答案,然后从侧边栏的one of the related questions找到答案。
我需要做的就是将以下内容添加到我的动画师中:
toViewController.view.frame = fromViewController.view.frame
我希望有一天能帮助别人。