我希望ButtonA
保持原状,ButtonB
将距离x垂直向下移动远离它。
答案 0 :(得分:0)
// Using Autolayout.
UIButton *buttonA, *buttonB;
UIView *fatherView; // The superview of buttonA and B.( The view where they are inside).
CGFloat distance;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:buttonB attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:buttonA attribute:NSLayoutAttributeBottom multiplier:1 constant:distance];
[fatherView addConstraint:constraint];
// Without autolayout, maybe more easy.
buttonB.center = CGPointMake(buttonA.center.x, buttonA.center.y + distance);