Skip to content

Instantly share code, notes, and snippets.

@NickHung1982
Created November 4, 2017 21:24
Show Gist options
  • Save NickHung1982/f39b8110e78cc76de9a93d099c8a8dd9 to your computer and use it in GitHub Desktop.
Save NickHung1982/f39b8110e78cc76de9a93d099c8a8dd9 to your computer and use it in GitHub Desktop.
update with use anchor
//setup centerY with cell
//let labelConstraintCenterY = NSLayoutConstraint(item: customLabel, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1, constant: 0)
//setup uilabel's height is equal 21
//let labelConstraintHeight = NSLayoutConstraint(item: customLabel, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1.0, constant: 21)
//self.addConstraints([labelConstraintCenterY])
//Update use layout Anchor
customLabel.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
customLabel.heightAnchor.constraint(equalToConstant: 21).isActive = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment