Open imzyf opened 6 years ago
self.topConstraint?.update(offset: 60)
override func updateViewConstraints() {
self.box.snp.updateConstraints{ (make) -> Void in
//视图宽度与屏幕等宽
make.width.equalTo(self.view)
}
super.updateViewConstraints()
}
我们还可以用 snp.updateConstraints 方法来代替 snp.makeConstraints 进行约束的更新,这个更新操作通常放在 UIViewController 的 updateViewConstraints() 方法中,或者 UIView 的 updateConstraints() 方法中执行,这样视图约束需要更新的时候会自动调用。
snp.remakeConstraints 与 snp.makeConstraints 用法类似,不同的是 snp.remakeConstraints 首先会先清除掉之前所有被SnapKit设置的约束。
box.snp.remakeConstraints { (make) -> Void in
make.width.height.equalTo(100)
}
http://www.hangge.com/blog/cache/detail_1110.html
删除约束