我只是想出如何动画插入一个 viewControll
[self transitiontoViewController:self.filterController duration:.5 options:UIViewAnimationOptionTransitionNone animations:^{
[self.filterController.view resizeandMovewithRect:CGRectMake(0, self.filterController.view.frame.size.height, 0, 0)];
} completion:^(BOOL finished){
}];
在这里,resizeAndMovewithRect 只是使用 UIView 的这个类别来移动视图
-(void) resizeandMovewithRect:(CGRect)movement
{
CGRect myFrame = self.frame;
CGRect newFrame = CGRectMake(myFrame.origin.x+movement.origin.x, myFrame.origin.y + movement.origin.y, myFrame.size.width + movement.size.width , myFrame.size.height + movement.size.height);
self.frame =newFrame;
}
现在我想做相反的事情。我希望通过将 self.filterController 移出屏幕来将其解散。
一种方法是:
[self transitiontoViewController:self.filterController duration:.5 options:UIViewAnimationOptionTransitionNone animations:^{
[self.filterController.view resizeandMovewithRect:CGRectMake(0, -self.filterController.view.frame.size.height, 0, 0)];
} completion:^(BOOL finished){
}];
如果我这样做,则根本不会绘制动画。
在我看来,self.filterController 在动画开始时已从超级视图中删除。这就是为什么看不到 self.filterController 发生的任何事情的原因。所以我这样做
[UIView animateWithDuration:.5 animations:^{
[self.filterController.view resizeandMovewithRect:CGRectMake(0, -self.filterController.view.frame.size.height, 0, 0)];
} completion:^(BOOL finished){
[self transitiontoViewController:self.last2ViewsInTheContainer[0] duration:0 options:UIViewAnimationOptionTransitionNone animations:^{
} completion:nil];
}];
所以我在调用 [self transitiontoViewController
但是,如果我这样做,那么当 self.filterController.view 被卷起时,正在替换它的视图还没有添加到 superview 中。所以那一个是看不见的。
无论如何我应该怎么做?