Created
July 6, 2018 16:32
-
-
Save jalakoo/9df74d84c715cfbb2d46ceb155a0909c to your computer and use it in GitHub Desktop.
Swift UIView simple fading extensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func reveal() { | |
if self.alpha == 1.0 { | |
return | |
} | |
UIView.animate(withDuration: 0.5) { | |
self.alpha = 1.0 | |
self.isUserInteractionEnabled = true | |
} | |
} | |
func hide() { | |
if self.alpha == 0.0 { | |
return | |
} | |
UIView.animate(withDuration: 0.5) { | |
self.alpha = 0.0 | |
} | |
} | |
func dim() { | |
if self.alpha == 0.5 { | |
return | |
} | |
UIView.animate(withDuration: 0.5) { | |
self.alpha = 0.5 | |
self.isUserInteractionEnabled = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment