下面的代码是将标签的x位置移动200pts而不是动画
[UIView animateWithDuration:500.0f animations:^{
self.myLabelContraint.constant=200 ;
[self.view layoutIfNeeded];
}];
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *myLabelContraint;
以上属性连接到超级视图的前导空间
故事板图片
检查员面板中的Autolayout约束
答案 0 :(得分:-2)
[self.view layoutIfNeeded];如果需要布局^ _ ^ 尝试在它之前添加字符串setMethod;
[UIView animateWithDuration:500.0f animations:^{
self.myLabelContraint.constant=200; //This string can be place somewhere
[self.view setNeedsLayout];
[self.view layoutIfNeeded];
}];