我想在屏幕上水平分隔未知数量的按钮。我想知道我是否可以互相创建他们的间距。例如,下面的代码可以工作吗?
let button1 = UIButton()
let button2 = UIButton()
superview.addSubview(button1)
superview.addSubview(button2)
button1.snp_makeConstraints { (make) -> Void in
make.height.equalTo(100)
make.top.equalTo(50)
make.left.equalTo(superview.snp.left)
make.right.equalTo(button2.snp.right)
make.width.lessThanOrEqualToSuperview()
}
button2.snp_makeConstraints { (make) -> Void in
make.width.lessThanOrEqualToSuperview()
make.height.equalTo(100)
make.top.equalTo(50)
make.left.equalTo(button1.snp.left)
make.right.equalTo(superview.snp.right)
}