No Description

AlertAnimator.swift 954B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // AlertAnimator.swift
  3. // PaiAi
  4. //
  5. // Created by FFIB on 2018/12/17.
  6. // Copyright © 2018 FFIB. All rights reserved.
  7. //
  8. import UIKit
  9. public struct AlertAnimator: PresentAnimatable {
  10. public init() {}
  11. public func contentViewAppearAnimation(duration: TimeInterval, in view: UIView) {
  12. let animation = CABasicAnimation(keyPath: "transform.scale")
  13. animation.toValue = 1
  14. animation.fromValue = 0
  15. animation.duration = duration
  16. animation.isRemovedOnCompletion = true
  17. view.layer.add(animation, forKey: nil)
  18. }
  19. public func contentViewDisappearAnimation(duration: TimeInterval, in view: UIView) {
  20. let animation = CAKeyframeAnimation(keyPath: "transform.scale")
  21. animation.values = [1, 1.1, 0]
  22. animation.duration = duration
  23. animation.isRemovedOnCompletion = false
  24. animation.fillMode = .forwards
  25. view.layer.add(animation, forKey: nil)
  26. }
  27. }