- (instancetype) updateMultiplier:(CGFloat)multiplier {
[NSLayoutConstraint deactivateConstraints:[NSArray arrayWithObjects:self, nil]];
NSLayoutConstraint *newConstraint = [NSLayoutConstraint constraintWithItem:self.firstItem
attribute:self.firstAttribute
relatedBy:self.relation
toItem:self.secondItem
attribute:self.secondAttribute
multiplier:multiplier
constant:self.constant];
[newConstraint setPriority:self.priority];
newConstraint.shouldBeArchived = self.shouldBeArchived;
newConstraint.identifier = self.identifier;
newConstraint.active = true;
[NSLayoutConstraint activateConstraints:[NSArray arrayWithObjects:newConstraint, nil]];
return newConstraint;
}
/// Usage
@property(nonatomic, strong) NSLayoutConstraint contraintCenterX;
self.constraintCenterX = [self.constraintCeterX updateMultiplier:0.6];
2017년 3월 30일 목요일
iOS update multiplier value of NSLayoutConstraint
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기