如何在基于导航的应用程序中为 backbarbuttonitem 使用翻转动画,默认情况下,它作为我们导航的上一个视图的弹出窗口?我只想将翻转动画添加到基于导航的应用程序中。
问问题
425 次
1 回答
0
为此,您需要将默认的后退按钮替换为自定义后退按钮。它不会是箭头按钮,因为据我所知,箭头导航按钮仅存在于私有 API 中。
要创建您的按钮,请执行以下操作:
UIBarButtonItem *customBackButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(flipPopView)];
self.navigationItem.leftBarButtonItem = customBackButton;
[customBackButton release];
接下来,您需要创建flipPopView
实际翻转的方法:
- (void)flipPopView {
// animateView should be whichever view you want the animation to occur in.
UIView *animateView = self.navigationController.view;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:animateView cache:YES];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
}
我基于我的一些类似代码进行了此操作,但它对您的工作方式可能有所不同。如果您有问题,请告诉我,我会看看我能做些什么。
于 2011-06-21T21:01:29.190 回答