暂无描述

NavigationBarInOut.swift 977B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // NavigationBarInOut.swift
  3. // PaiaiUIKit
  4. //
  5. // Created by ffib on 2019/1/15.
  6. // Copyright © 2019 yb. All rights reserved.
  7. //
  8. import UIKit
  9. public protocol NavigationBarInOut: class {
  10. var navigationView: UIView { get }
  11. func navigationBarFadeIn()
  12. func navigationBarFadeOut()
  13. func navigationBarFadeOutWithPercentage(_ percentage: CGFloat)
  14. }
  15. public extension NavigationBarInOut where Self: UIViewController {
  16. func navigationBarFadeIn() {
  17. UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: [], animations: {
  18. self.navigationView.alpha = 0
  19. }, completion: nil)
  20. }
  21. func navigationBarFadeOut() {
  22. UIView.animate(withDuration: 0.5, animations: {
  23. self.navigationView.alpha = 1
  24. }, completion: nil)
  25. }
  26. func navigationBarFadeOutWithPercentage(_ percentage: CGFloat) {
  27. self.navigationView.alpha = 1 * percentage
  28. }
  29. }