有没有办法使用 UIViewAnimationOptionTransitionCurlUp 而不对整个屏幕进行动画处理?

发布于 2024-10-12 03:18:36 字数 929 浏览 7 评论 0原文

我有一个具有以下层次结构的视图控制器:

UIViewController
|
|-视图
    |-presentView (UIView)
    |-stagedView (UIView)
   |-UIToolbar

我正在使用 transitionFromView:toView:duration:options:completion: 方法来动画页面卷曲以在 presentView 和 stagedView。当前和分阶段视图仅覆盖屏幕的大部分,并且底部有一个 UIToolbar。当我使用 UIViewAnimationOptionTransitionCurlUp 过渡时,它会为整个根视图(包括工具栏)设置动画,而不仅仅是涉及的两个视图。

[UIView transitionFromView:self.presentView
                    toView:self.stagedView 
                  duration:0.5f 
                   options:UIViewAnimationOptionTransitionCurlUp
                completion:^ (BOOL finished) {
                                   if (finished) {
                                      // cleanup code
                                   }}];

有没有办法只对两个子视图进行动画处理,而不影响工具栏?如果是这样,怎么办?

I have a view controller that has the following hierarchy:

UIViewController
|
|-view
    |-presentView (UIView)
    |-stagedView (UIView)
    |-UIToolbar

I am using the transitionFromView:toView:duration:options:completion: method to animate a page curl up to swap between the presentView and the stagedView. The present and staged view only cover most of the screen and there is a UIToolbar at the bottom. When I use the UIViewAnimationOptionTransitionCurlUp transition, it is animating the whole root view (toolbar included), not just the two views involved.

[UIView transitionFromView:self.presentView
                    toView:self.stagedView 
                  duration:0.5f 
                   options:UIViewAnimationOptionTransitionCurlUp
                completion:^ (BOOL finished) {
                                   if (finished) {
                                      // cleanup code
                                   }}];

Is there a way to only animate the two subviews, leaving the toolbar alone? If so, how?

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

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

发布评论

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

评论(3

数理化全能战士 2024-10-19 03:18:36

我一直在努力解决这个问题,解决这个问题的唯一方法是将 fromView 放入另一个视图中。在您的情况下,视图层次结构应如下所示:

UIViewController
|
|-view
   |-containerView
      |-presentView
   |-stagedView
   |-UIToolBar

fromView 参数仍应指向presentView。希望这有帮助。

I've been struggling with this issue and the only way I could resolve it is that I put the fromView into another view. In your case the view hierarchy should look like this:

UIViewController
|
|-view
   |-containerView
      |-presentView
   |-stagedView
   |-UIToolBar

The fromView parameter still should point to presentView. Hope this helps.

岁月如刀 2024-10-19 03:18:36

本教程完美地解释了这一点。

http://joris.kluivers.nl/iphone-dev/?p=CurlTransition

基本上,您想要创建一个容器视图,这将是我们将要制作动画的视图,您可以将其称为“containerView”。该容器视图已经添加了一个子视图,该子视图可以填充整个容器视图。然后,当您想要动画到下一个视图时,请使用下面的代码。您删除当前视图并添加下一个视图。最后,你真的在​​你的containerView之间进行转换。它本身在动画开始语句之后被更改。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:NO];
[presentView removeFromSuperview];
[containerView addSubview:nextView];
[UIView commitAnimations];

This tutorial explains it perfectly.

http://joris.kluivers.nl/iphone-dev/?p=CurlTransition

Basically, you want to create a container view which will be the view we'll be animating, you could call it containerView. This container view will already have a subview added to it which can fill the entire containerView. Then use the code below when you want to animate to the next view. You remove the present view and add the next view. In the end, you are really transitioning between your containerView. Which itself is being changed after the animation begin statement.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:NO];
[presentView removeFromSuperview];
[containerView addSubview:nextView];
[UIView commitAnimations];
蓝咒 2024-10-19 03:18:36

韦恩我建议你使用选项卡栏,然后实现它的委托方法。我刚刚为你做了

   - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    {
        //NSArray *vc= tabBarController.viewControllers;
    //  for (int i = 0; i < [vc count]; i++) {
    //      UINavigationController *nc = [vc objectAtIndex:i];
    //      if (nc == tabBarController.selectedViewController) {
    //          continue;
    //      }
            [UIView beginAnimations:@"animation" context:nil];
            //[self.navigationController pushViewController:nc.topViewController animated:NO]; 
            [UIView setAnimationDuration:1.5];
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view cache:NO]; 
            [UIView commitAnimations];
        return TRUE;

    }

这只是选项卡栏的逻辑,它只翻转视图而不是选项卡栏。所以我希望你也可以使用工具栏。
好吧,它只是给你一个想法。希望它能帮助你

Wayne i suggest you to use the tab bar and then implement its delegate method.I just did it for you

   - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    {
        //NSArray *vc= tabBarController.viewControllers;
    //  for (int i = 0; i < [vc count]; i++) {
    //      UINavigationController *nc = [vc objectAtIndex:i];
    //      if (nc == tabBarController.selectedViewController) {
    //          continue;
    //      }
            [UIView beginAnimations:@"animation" context:nil];
            //[self.navigationController pushViewController:nc.topViewController animated:NO]; 
            [UIView setAnimationDuration:1.5];
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view cache:NO]; 
            [UIView commitAnimations];
        return TRUE;

    }

Here is just the logic with the tab bar,it only flips the view not the tabbar.So i hope the same you could with ToolBar.
Well it will just give you idea.Hope it could help you

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