如何以編程方式修改約束的乘數?我已經設置了以下情況:以編程方式修改約束的乘數限制
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:0.5 constant:0.0]];
,我需要修改它這樣的:
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:_button attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0]];
我不認爲有辦法改變乘數,但你可以刪除約束並設置新的。 – almas
在這裏回答http://stackoverflow.com/questions/19593641/can-i-change-multiplier-property-for-nslayoutconstraint – user3125367
我結束了使用常數,而不是乘數。 –