Skip to content

Instantly share code, notes, and snippets.

@jalakoo
Created July 6, 2018 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalakoo/9df74d84c715cfbb2d46ceb155a0909c to your computer and use it in GitHub Desktop.
Save jalakoo/9df74d84c715cfbb2d46ceb155a0909c to your computer and use it in GitHub Desktop.
Swift UIView simple fading extensions
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