How can I set the aspect ratio constraint to a 1:1 ratio of width:height on a UIButton programmatically in swift? This image shows in Interface Builder what I want to achieve through code.
Try this
myButton.addConstraint(NSLayoutConstraint(item: myButton, attribute: .height, relatedBy: .equal, toItem: myButton, attribute: .width, multiplier: 1, constant: 0))