Skip to content

Instantly share code, notes, and snippets.

@kylebshr
Last active September 28, 2017 03:12
Show Gist options
  • Save kylebshr/a61f135d7f694d3a1544dabccfe7caf4 to your computer and use it in GitHub Desktop.
Save kylebshr/a61f135d7f694d3a1544dabccfe7caf4 to your computer and use it in GitHub Desktop.
extension UIView {
/// Sets `isHidden` but only if the new value is different from the existing one.
/// Fixes http://stackoverflow.com/questions/33240635/hidden-property-cannot-be-changed-within-an-animation-block
var safeIsHidden: Bool {
get {
return isHidden
}
set {
if newValue != isHidden {
isHidden = newValue
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment