I want to space an unknown amount of buttons equally across the screen horizontally. I was wondering if I could create their spacing based off each other. For example will the code below work?
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)
}