Skip to content

Instantly share code, notes, and snippets.

@regnerjr
Created December 6, 2017 18:45
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 regnerjr/3b46e538a98b86549555eadef30615dd to your computer and use it in GitHub Desktop.
Save regnerjr/3b46e538a98b86549555eadef30615dd to your computer and use it in GitHub Desktop.
A UIView Extension to help debug auto layout issues
extension UIView {
func exerciseAmbiguityInLayoutRepeatedly(_ recursive: Bool) {
#if DEBUG
if hasAmbiguousLayout {
Timer.scheduledTimer(timeInterval: 0.5,
target: self,
selector: #selector(exerciseAmbiguityInLayout),
userInfo: nil,
repeats: true)
}
if recursive {
for subview in subviews {
subview.exerciseAmbiguityInLayoutRepeatedly(true)
}
}
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment