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.
            Asked
            
        
        
            Active
            
        
            Viewed 3,571 times
        
    1 Answers
8
            Try this
myButton.addConstraint(NSLayoutConstraint(item: myButton, attribute: .height, relatedBy: .equal, toItem: myButton, attribute: .width, multiplier: 1, constant: 0))
 
    
    
        maxwell
        
- 3,788
- 6
- 26
- 40

