<分区>
如何以编程方式快速将 UIButton 上的宽高比约束设置为 1:1 的宽高比? 此图像在 Interface Builder 中显示了我想通过代码实现的目标。
最佳答案
试试这个
myButton.addConstraint(NSLayoutConstraint(item: myButton, attribute: .height, relatedBy: .equal, toItem: myButton, attribute: .width, multiplier: 1, constant: 0))
关于ios - 1 :1 width:height constraint to UIButton programmatically,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49279316/