【发布时间】:2015-04-04 04:04:20
【问题描述】:
我试图在用户按下 uiviewcontroller 导航栏的默认后退按钮(不是自定义按钮)时产生自定义效果。我试图在弹出视图之前将 uiview 向下移动到某个 Y 位置并让视图控制器消失。
我尝试了两种方法:
方法一
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[UIView animateWithDuration:0.2 animations:^{
self.cvCell.frame = self.selectedCellFrame;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.navigationController.view cache:NO];
} completion:^(BOOL finished) {
[self.navigationController popViewControllerAnimated:NO];
}];
}];
}
方法二:
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
[UIView animateWithDuration:0.2 animations:^{
self.cvCell.frame = self.selectedCellFrame;
} completion:^(BOOL finished) {
CATransition *transition = [CATransition animation];
[transition setDuration:0.75];
[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[transition setType:kCATransitionReveal];
[transition setSubtype:kCATransitionFromLeft];
[transition setDelegate:self];
[self.navigationController.view.layer addAnimation:transition forKey:nil];
}];
}
}
在这两种情况下,视图都会在 UIView 上的动画启动之前消失。 对实现这一目标有何建议?
【问题讨论】:
标签: ios objective-c uinavigationcontroller pushviewcontroller