// // ActionSheetAnimator.swift // PaiAi // // Created by ffib on 2018/12/17. // Copyright © 2018 yb. All rights reserved. // import UIKit struct ActionSheetAnimator: AlertViewAnimatable { func contentViewAppearAnimation(duration: TimeInterval, in view: UIView) { let animation = CATransition() animation.duration = duration animation.type = kCATransitionMoveIn animation.subtype = kCATransitionFromTop view.layer.add(animation, forKey: nil) } func contentViewDisappearAnimation(duration: TimeInterval, in view: UIView) { let fromValue = view.layer.position.y let toValue = fromValue + view.bounds.height let animation = CABasicAnimation(keyPath: "position.y") animation.toValue = toValue animation.duration = duration animation.fromValue = fromValue animation.isRemovedOnCompletion = false animation.fillMode = kCAFillModeForwards view.layer.add(animation, forKey: nil) } }