XIB
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *bgViewRightConstraint;定義一個出來,然后self.bgViewRightConstraint.constant = -35;這樣使用修改就好
代碼
self.bgViewRightConstraint = [NSLayoutConstraint constraintWithItem:self.bgView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1 constant:15];
[self addConstraint:self.bgViewRightConstraint];