假设CustomView's
尺寸为 300x300。iconImageView
有它的大小和指定的约束。我不知道文本要输入多长时间,UILabel
所以我不想让UILabel
. 我的目标是将左侧约束固定到右侧iconImageView
,右侧固定到customView
.
override func updateConstraints() {
super.updateConstraints()
iconImageView.snp.updateConstraints { (make) in
make.left.equalTo(customView).offset(10)
make.centerY.equalTo(customView)
make.size.equalTo(CGSize(width: 40.0, height: 40.0))
}
nameLabel.snp.updateConstraints { (make) in
make.right.equalTo(customView).offset(-10)
make.left.equalTo(iconImageView.snp.right).offset(10)
make.centerY.equalTo(customView)
}
}
当我尝试这种方法时,我得到错误:Unable to simultaneously satisfy constraints.
这样做的正确方法是什么?