Skip to content

Instantly share code, notes, and snippets.

@MylesCaley
Created November 18, 2016 17:31
Show Gist options
  • Save MylesCaley/c5d7ebe83dd5d782a9ba5d4b4108fc16 to your computer and use it in GitHub Desktop.
Save MylesCaley/c5d7ebe83dd5d782a9ba5d4b4108fc16 to your computer and use it in GitHub Desktop.
its possible to create multiple constraints for the same object, then change the priority
// instead of creating and destroying constraints all the time we can just
// add multiple constraints on the same object and then change the priority
// and indicate which one is active
if feedItem!.prototypeUpdate?.media.count <= 1 {
mediaViewWidthConstraintLarge.priority = 995
mediaViewWidthContraint.priority = 999
mediaViewWidthConstraintLarge.isActive = true
mediaViewWidthContraint.isActive = false
} else {
mediaViewWidthConstraintLarge.priority = 999
mediaViewWidthContraint.priority = 995
mediaViewWidthConstraintLarge.isActive = false
mediaViewWidthContraint.isActive = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment