(IOS)约束如何做UIView动画?

1、把需要改的约束Constraint拖条线出来,成为属性

2、在需要动画的地方加入代码,改变此属性的constant属性

3、开始做UIView动画,动画里边调用layoutIfNeeded方法

@property(weak, nonatomic)IBOutletNSLayoutConstraint *buttonTopConstraint;

self.buttonTopConstraint.constant =100;

[UIView animateWithDuration:.5animations:^{

    [self.view layoutIfNeeded];

}];

你可能感兴趣的:((IOS)约束如何做UIView动画?)