signUpButton.translatesAutoresizingMaskIntoConstraints = false
signUpButton.widthAnchor.constraint(equalToConstant: 128).isActive = true
signUpButton.heightAnchor.constraint(equalToConstant: 64).isActive = true
signUpButton.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
signUpButton.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
signUpButton.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
- NSLayoutConstraint: UIButton:'Sign Up'.width == 128 (active),
- NSLayoutConstraint: H:|-(0)-[UIButton:'Sign Up'] (active, names: '|':UIView: ),
- NSLayoutConstraint: UIButton:'Sign Up'.trailing == UIView:.trailing (active),
- NSLayoutConstraint: 'UIView-Encapsulated-Layout-Width' UIView:.width == 375 (active)
Will attempt to recover by breaking constraint NSLayoutConstraint: UIButton:'Sign Up'.width == 128 (active)>
I want to put my button to center of leading and trailing anchors with certain width but when I run the code the button expands to those anchors. How can I prevent that expansion?
.isActive = true
with the user ofNSLayoutContraint.activate()
. – rmaddy