0
我正在使用自动布局,并试图在屏幕上和屏幕上滑动视图。我已经尝试了几种方法,一些来自stackoverflow和一些来自Apple文档,但没有任何作用。视图只是在屏幕上弹出,无论我在动画时使用了多长时间。如何正确设置动画约束?
正如您在下面看到的,我尝试了几种方法。什么都没有隐藏和显示他们都只是弹出和关闭屏幕(即不是动画)。
-(void)hideButtons {
[self.view layoutIfNeeded]; // Ensures that all pending layout operations have been completed
[UIView animateWithDuration:1.5f animations:^{
self.leftSideConstraint.constant = 300;
[self.view layoutIfNeeded];
}];
}
-(void)showButtons {
//[self.view layoutIfNeeded]; // Ensures that all pending layout operations have been completed
self.leftSideConstraint.constant = 87;
[self.view setNeedsUpdateConstraints];
[UIView animateWithDuration:1.5f animations:^{
[self.view layoutIfNeeded];
}];
}
self.leftSideConstraint属于self.view的子视图 – jdog