Guest User

Untitled

a guest
Nov 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. extension UIView {
  2.  
  3. func show(animated: Bool) {
  4. self.isHidden = false
  5. if animated {
  6. UIView.animate(
  7. withDuration: animationDuration,
  8. animations: {
  9. self.alpha = 1
  10. }
  11. )
  12. } else {
  13. self.alpha = 1
  14. }
  15. }
  16.  
  17. func hide(animated: Bool) {
  18. if animated {
  19. UIView.animate(
  20. withDuration: animationDuration,
  21. animations: {
  22. self.alpha = 0
  23. },
  24. completion: { _ in
  25. self.isHidden = true
  26. }
  27. )
  28. } else {
  29. self.alpha = 0
  30. self.isHidden = true
  31. }
  32. }
  33.  
  34. }
  35.  
  36. fileprivate var animationDuration: TimeInterval = 0.3
Add Comment
Please, Sign In to add comment