Skip to content

Instantly share code, notes, and snippets.

@shakemno
Created January 31, 2019 13:41
Show Gist options
  • Select an option

  • Save shakemno/edaba2d514384df0a373f83bf478d965 to your computer and use it in GitHub Desktop.

Select an option

Save shakemno/edaba2d514384df0a373f83bf478d965 to your computer and use it in GitHub Desktop.
Get a constraint by identifier - without the need of using a property
// add .identifier
let centerXConstraint = view.centerXAnchor.constraint(equalTo: centerXAnchor, constant: 0)
centerXConstraint.identifier = "IdentifierName"
// get constraint
let constraintByIdentifier = view.constraints.filter ({ $0.identifier == "IdentifierName" }).first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment