基于导航的应用程序的翻转动画

发布于 2024-11-16 15:46:50 字数 96 浏览 2 评论 0原文

如何在基于导航的应用程序中使用 backbarbuttonitem 的翻转动画,默认情况下,该动画充当我们导航的上一个视图的弹出窗口?我只想将翻转动画添加到基于导航的应用程序中。

How can I use a flip animation for backbarbuttonitem in a navigation based application, which by default acts as a pop to previous view from which we navigated from? I just want to add flip animation to my navigation based application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾`听者〃 2024-11-23 15:46:50

为此,您需要将默认后退按钮替换为自定义后退按钮。它不会是一个箭头按钮,因为据我所知,箭头导航按钮只存在于私有 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];

}

我基于一些类似的代码,但它对您来说可能会有所不同。如果您遇到问题,请告诉我,我会看看我能做些什么。

To do this, you will need to replace the default back button with a custom back button. It will not be an arrow button, because as far as I am aware, the arrow navigation button only exists in a private API.

To create your button, do something like this:

UIBarButtonItem *customBackButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(flipPopView)];

self.navigationItem.leftBarButtonItem = customBackButton;

[customBackButton release];

Next you need to create the flipPopView method to actually flip back:

- (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];

}

I based this off of some of my similar code, but it might work differently for you. Let me know if you have problems, and I'll see what I can do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文