我有一个UIView
当我打开视图控制器从顶部飞。我给自己定了UIView
的Y约束至-200和当视图加载,下面的叫,一切工作正常:问题与UIView的自动布局动画
- (void)updateViewConstraints
{
[super updateViewConstraints];
self.popUpViewYConstraint.constant = 37.0f;
self.closeButtonYConstraint.constant = 28.0f;
[self.popUpBaseView setNeedsUpdateConstraints];
[self.closeButton setNeedsUpdateConstraints];
[UIView animateWithDuration:0.25f animations:^{
[self.popUpBaseView layoutIfNeeded];
[self.closeButton layoutIfNeeded];
[self.view layoutIfNeeded];
}];
}
但现在我有一个关闭按钮应该动画UIView
回-200位置,然后从屏幕上移除视图控制器。但是这个动画没有发生。视图控制器正在被直接删除。这是我在做什么:
- (IBAction)closePressed:(id)sender
{
NSMutableArray *navigationArray = [[NSMutableArray alloc] initWithArray: self.navigationController.viewControllers];
self.navigationController.viewControllers = navigationArray;
[UIView animateWithDuration:2.0f animations:^{
self.popUpViewYConstraint.constant = -200.0f;
[self.popUpBaseView layoutIfNeeded];
} completion:^(BOOL finished){
[navigationArray removeObjectAtIndex: 1];
[self.baseView removeFromSuperview];
[self.view removeFromSuperview];
}];
}
我提到this链接。它似乎在为他们工作,但不适合我。 请帮忙。
如果删除,消除意见的代码会发生什么? (即只让完成块变空白)。另外,试试这个...'animateWithDuration:延迟:选项:动画:completion',而不是你的选项使用一个... UIViewAnimationOptionBeginFromCurrentState – Fogmeister
什么也没有发生。视图控制器只是删除没有动画。 – Anil
你可以在动画使视图出现之前和之后放置一个屏幕截图。 – Fogmeister