私はライブラリを開発しており、2つのView Controller間でデフォルトのカスタムトランジションを提供したいと考えています。ユーザーは自分の実装を提供することもできます。 UIViewControllerTransitioningDelegate
し、ユーザーは私のCustomTransitionViewController
をサブクラス化することができますそれを行うには、最善の方法ですか?どんな制限?たとえば、デフォルトの実装では単にプロトコルを使用するよりエレガントな方法がありますか?UIViewControllerの既定のカスタムトランジション
import UIKit
class CustomTransitionViewController: UIViewController, UIViewControllerTransitioningDelegate {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.transitioningDelegate = self
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil:Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.transitioningDelegate = self
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FadeInAnimator(transitionDuration: 0.5, startingAlpha: 0.8)
}
func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return FadeInAnimator(transitionDuration: 0.5, startingAlpha: 0.8)
}
}