我应该如何使用Swift实现此方法调用?
[containerViewController transitionFromViewController:fromViewController
toViewController:toViewController
duration:0.2
options:UIViewAnimationOptionTransitionCrossDissolve
animations:nil
completion:^(BOOL finished) {
[fromViewController removeFromParentViewController];
[toViewController didMoveToParentViewController:containerViewController];
toViewController.view.frame = containerViewController.view.bounds;
}];
====
containerViewController.transitionFromViewController(
fromViewController,
toViewController,
0.2,
UIViewAnimationOptionTransitionCrossDissolve,
nil,
nil)
我收到此错误:使用未解析的标识符'UIViewAnimationOptionTransitionCrossDissolve'
答案 0 :(得分:8)
工作解决方案:
containerViewController.transitionFromViewController(
fromViewController,
toViewController: toViewController,
duration: 0.2,
options: UIViewAnimationOptions.TransitionCrossDissolve,
nil,
completion: { finished in
fromViewController.removeFromParentViewController()
toViewController.didMoveToParentViewController(containerViewController)
toViewController.view.frame = containerViewController.view.bounds
})
答案 1 :(得分:2)
写.TransitionCrossDissolve
代替UIViewAnimationOptionTransitionCrossDissolve
。类型UIViewAnimationOption
是已知的方法,可以推断出来。
答案 2 :(得分:0)
斯威夫特3:
containerViewController.transition(from: fromViewController,
to: toViewController,
duration: 0.2,
options: .transitionCrossDissolve,
nil,
completion: { _ in
fromViewController.removeFromParentViewController()
toViewController.didMove(toParentViewController: containerViewController)
toViewController.view.frame = containerViewController.view.bounds
})