import Foundation
import UIKit
enum TransitionType {
case Presenting, Dismissing
}
class AnimationController: NSObject, UIViewControllerAnimatedTransitioning {
var duration: NSTimeInterval
var isPresenting: Bool
var originFrame: CGRect
init(withDuration duration: NSTimeInterval, forTransitionType type: TransitionType, originFrame: CGRect) {
self.duration = duration
self.isPresenting = type == .Presenting
self.originFrame = originFrame
super.init()
}
func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
return self.duration
}
}
代码改编自以下教程: