I am trying to set the width UIButtonusing this code:
constraintButtonPlayWidth = NSLayoutConstraint(item: buttonPlay,
attribute: NSLayoutAttribute.Width,
relatedBy: NSLayoutRelation.Equal,
toItem: self.view,
attribute: NSLayoutAttribute.Width,
multiplier: 1,
constant: 100)
self.view.addConstraint(constraintButtonPlayWidth)
But the button is stretched too much; probably because toItem: self.view. I tried to change the constraint constant, but that didn't change anything.
How to properly configure this restriction so that it has a width of 100?
source
share