暂无描述

PresentAnimatable.swift 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // PresentAnimatable.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 protocol PresentAnimatable {
  10. func toViewPresentedAnimation(duration: TimeInterval, in view: UIView)
  11. func fromViewPresentingAnimation(duration: TimeInterval, in view: UIView)
  12. func contentViewAppearAnimation(duration: TimeInterval, in view: UIView)
  13. func contentViewDisappearAnimation(duration: TimeInterval, in view: UIView)
  14. }
  15. public extension PresentAnimatable {
  16. func toViewPresentedAnimation(duration: TimeInterval, in view: UIView) {
  17. UIView.transition(with: view, duration: duration, options: [], animations: {
  18. view.backgroundColor = UIColor(red: 52 / 255,
  19. green: 52 / 255,
  20. blue: 52 / 255,
  21. alpha: 0.7)
  22. })
  23. }
  24. func fromViewPresentingAnimation(duration: TimeInterval, in view: UIView) {
  25. UIView.transition(with: view, duration: duration, options: [], animations: {
  26. view.backgroundColor = UIColor(red: 52 / 255,
  27. green: 52 / 255,
  28. blue: 52 / 255,
  29. alpha: 0)
  30. })
  31. }
  32. }