NSLayoutConstraint *btn2Left = [NSLayoutConstraint constraintWithItem:imagebtn2 attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:imagebtn1 attribute:NSLayoutAttributeRight multiplier:1.0 constant:8.0];
这么写的,其实就是我在button初始化的时候写了约束,后来需要重新设置button,此时的约束不知道怎么更新了
你如果只变一个,用一个property指向不就可以了
约束有多种做法,不知道楼主用的是什么来做的约束,说明白点
其实一般来说大家都用masonry。
楼主这不是已经拿到了constraint的指针了么?在需要更新约束的地方重新给这个指针赋值,然后[buttonsParentView setNeedsUpdateConstraints];就可以了。
已解决,我的方法是改变了有冲突约束的优先级