<bdo id='ry25v'></bdo><ul id='ry25v'></ul>
    1. <small id='ry25v'></small><noframes id='ry25v'>

      1. <legend id='ry25v'><style id='ry25v'><dir id='ry25v'><q id='ry25v'></q></dir></style></legend>

      2. <i id='ry25v'><tr id='ry25v'><dt id='ry25v'><q id='ry25v'><span id='ry25v'><b id='ry25v'><form id='ry25v'><ins id='ry25v'></ins><ul id='ry25v'></ul><sub id='ry25v'></sub></form><legend id='ry25v'></legend><bdo id='ry25v'><pre id='ry25v'><center id='ry25v'></center></pre></bdo></b><th id='ry25v'></th></span></q></dt></tr></i><div id='ry25v'><tfoot id='ry25v'></tfoot><dl id='ry25v'><fieldset id='ry25v'></fieldset></dl></div>
        <tfoot id='ry25v'></tfoot>

        改变动画过渡

        时间:2023-05-17
            <bdo id='TlNPf'></bdo><ul id='TlNPf'></ul>
              <tfoot id='TlNPf'></tfoot>

                <small id='TlNPf'></small><noframes id='TlNPf'>

                    <tbody id='TlNPf'></tbody>
                  <legend id='TlNPf'><style id='TlNPf'><dir id='TlNPf'><q id='TlNPf'></q></dir></style></legend>
                  <i id='TlNPf'><tr id='TlNPf'><dt id='TlNPf'><q id='TlNPf'><span id='TlNPf'><b id='TlNPf'><form id='TlNPf'><ins id='TlNPf'></ins><ul id='TlNPf'></ul><sub id='TlNPf'></sub></form><legend id='TlNPf'></legend><bdo id='TlNPf'><pre id='TlNPf'><center id='TlNPf'></center></pre></bdo></b><th id='TlNPf'></th></span></q></dt></tr></i><div id='TlNPf'><tfoot id='TlNPf'></tfoot><dl id='TlNPf'><fieldset id='TlNPf'></fieldset></dl></div>
                  本文介绍了改变动画过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个带有 NavigationController 的应用程序.如何更改 pushViewControllerpopToViewController 的动画过渡样式?

                  I got an app with NavigationController. How can i change animation transition style of pushViewController and popToViewController?

                  更新

                  我在@lawicko 答案中创建了类别.但是当我尝试调用函数时出现错误

                  I created category like in @lawicko answer. But i got error when i am trying to call function

                  [self.navigationController pushViewController:places withCustomTransition:CustomViewAnimationTransitionPush subtype:CustomViewAnimationSubtypeFromLeft];

                  [self.navigationController pushViewController:places withCustomTransition:CustomViewAnimationTransitionPush subtype:CustomViewAnimationSubtypeFromLeft];

                  错误是:使用未声明的标识符'CustomViewAnimationTransitionPush'"

                  error is : "use of undeclared identifier 'CustomViewAnimationTransitionPush'"

                  我应该在哪里声明这部分:

                  Where should i declare this part:

                  typedef enum {
                      CustomViewAnimationTransitionNone,
                      CustomViewAnimationTransitionFlipFromLeft,
                      CustomViewAnimationTransitionFlipFromRight,
                      CustomViewAnimationTransitionCurlUp,
                      CustomViewAnimationTransitionCurlDown,
                      CustomViewAnimationTransitionFadeIn,
                      CustomViewAnimationTransitionMoveIn,
                      CustomViewAnimationTransitionPush,
                      CustomViewAnimationTransitionReveal
                  } CustomViewAnimationTransition;
                  

                  现在写我在 UINavigationController+Additions.h

                  UPD 2:又一个新错误:

                  UPD 2: One more new error:

                  Undefined symbols for architecture i386:
                    "_OBJC_CLASS_$_CATransition", referenced from:
                        objc-class-ref in UINavigationController+Additions.o
                    "_kCATransition", referenced from:
                  

                  所有 _kCATransitions 的错误都相同

                  and same errors foor all _kCATransitions

                  推荐答案

                  查看我创建的这个 UINavigationController 类别.它允许您使用几乎所有可能的转换进行推送和弹出,并且还支持 QuartzCore 转换的子类型,这将允许您完全按照您的意愿执行 - 从左侧推送视图.这样做:

                  Check out this UINavigationController category that I created. It allows you pushing and popping with pretty much every possible transition, and also supports subtypes for QuartzCore transitions, which will allow you to do exactly what you want - push the view from the left. Do it like this:

                  [self.navigationController pushViewController:[[MyController alloc] init] withCustomTransition:CustomViewAnimationTransitionPush subtype:CustomViewAnimationSubtypeFromLeft];
                  

                  代码如下.第一部分你需要放在标题部分:

                  The code is below. The first part you need to put in the header part:

                  // IMPORTANT - basic transitions like flip and curl are local, they reside only in animation block. Core animations however,
                  // once assigned to the layer, stay until changed or reset (by assigning nil as layer animation property)
                  
                  #import <Foundation/Foundation.h>
                  #import <UIKit/UIKit.h>
                  #import <QuartzCore/QuartzCore.h>
                  
                  typedef enum {
                      CustomViewAnimationTransitionNone,
                      CustomViewAnimationTransitionFlipFromLeft,
                      CustomViewAnimationTransitionFlipFromRight,
                      CustomViewAnimationTransitionCurlUp,
                      CustomViewAnimationTransitionCurlDown,
                      CustomViewAnimationTransitionFadeIn,
                      CustomViewAnimationTransitionMoveIn,
                      CustomViewAnimationTransitionPush,
                      CustomViewAnimationTransitionReveal
                  } CustomViewAnimationTransition;
                  
                  #define CustomViewAnimationSubtypeFromRight kCATransitionFromRight
                  #define CustomViewAnimationSubtypeFromLeft kCATransitionFromLeft
                  #define CustomViewAnimationSubtypeFromTop kCATransitionFromTop
                  #define CustomViewAnimationSubtypeFromBottom kCATransitionFromBottom
                  
                  @interface UINavigationController(Additions)
                  
                  - (void)pushViewController:(UIViewController *)viewController withCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype;
                  
                  - (void)popViewControllerWithCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype;
                  - (void)popToRootViewControllerWithCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype;
                  - (void)popToViewController:(UIViewController *)viewController withCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype;
                  
                  @end
                  

                  您需要将第二部分放入实现文件中:

                  This second part you need to put in the implementation file:

                  #import "UINavigationController_Additions.h"
                  
                  @interface UINavigationController()
                  
                  - (void)standardAnimationWithController:(UIViewController*)viewController
                                                  duration:(NSTimeInterval)duration
                                                  options:(UIViewAnimationOptions)options
                                                  changesBlock:(void (^)(void))block;
                  - (void)coreAnimationWithController:(UIViewController*)viewController
                                                  duration:(NSTimeInterval)duration
                                                  type:(NSString*)type
                                                  subtype:(NSString*)subtype
                                                  changesBlock:(void (^)(void))block;
                  @end
                  
                  @implementation UINavigationController(Additions)
                  
                  #pragma mark -
                  #pragma mark pushing
                  
                  - (void)pushViewController:(UIViewController *)viewController withCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype {
                      switch (transition) {
                          case CustomViewAnimationTransitionNone:{
                              [self standardAnimationWithController:viewController duration:.5 options:UIViewAnimationOptionTransitionNone
                                                              changesBlock:^{
                                                                  [self pushViewController:viewController animated:NO];
                                                              }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromLeft:{
                              [self standardAnimationWithController:viewController duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft
                                                              changesBlock:^{
                                                                  [self pushViewController:viewController animated:NO];
                                                              }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromRight:{
                              [self standardAnimationWithController:viewController duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight
                                                              changesBlock:^{
                                                                  [self pushViewController:viewController animated:NO];
                                                              }];
                              break;}
                          case CustomViewAnimationTransitionCurlUp:{
                              [self standardAnimationWithController:viewController duration:.5 options:UIViewAnimationOptionTransitionCurlUp
                                                              changesBlock:^{
                                                                  [self pushViewController:viewController animated:NO];
                                                              }];
                              break;}
                          case CustomViewAnimationTransitionCurlDown:{
                              [self standardAnimationWithController:viewController duration:.5 options:UIViewAnimationOptionTransitionCurlDown
                                                              changesBlock:^{
                                                                  [self pushViewController:viewController animated:NO];
                                                              }];
                              break;}
                          case CustomViewAnimationTransitionFadeIn:{
                              [self coreAnimationWithController:viewController duration:.5 type:kCATransitionFade subtype:nil
                                                   changesBlock:^{
                                                       [self pushViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionMoveIn:{
                              [self coreAnimationWithController:viewController duration:.5 type:kCATransitionMoveIn subtype:subtype
                                                   changesBlock:^{
                                                       [self pushViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionPush:{
                              [self coreAnimationWithController:viewController duration:.5 type:kCATransitionPush subtype:subtype
                                                   changesBlock:^{
                                                       [self pushViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionReveal:{
                              [self coreAnimationWithController:viewController duration:.5 type:kCATransitionReveal subtype:subtype
                                                   changesBlock:^{
                                                       [self pushViewController:viewController animated:NO];
                                                   }];
                              break;}
                          default:{
                              break;}
                      }
                  }
                  
                  #pragma mark -
                  #pragma mark popping
                  
                  - (void)popViewControllerWithCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype {
                      switch (transition) {
                          case CustomViewAnimationTransitionNone:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionNone
                                                       changesBlock:^{
                                                           [self popViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromLeft:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft
                                                       changesBlock:^{
                                                           [self popViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromRight:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight
                                                       changesBlock:^{
                                                           [self popViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlUp:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlUp
                                                       changesBlock:^{
                                                           [self popViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlDown:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlDown
                                                       changesBlock:^{
                                                           [self popViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFadeIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionFade subtype:nil
                                                   changesBlock:^{
                                                       [self popViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionMoveIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionMoveIn subtype:subtype
                                                   changesBlock:^{
                                                       [self popViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionPush:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionPush subtype:subtype
                                                   changesBlock:^{
                                                       [self popViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionReveal:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionReveal subtype:subtype
                                                   changesBlock:^{
                                                       [self popViewControllerAnimated:NO];
                                                   }];
                              break;}
                          default:{
                              break;}
                      }
                  }
                  
                  - (void)popToRootViewControllerWithCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype {
                      switch (transition) {
                          case CustomViewAnimationTransitionNone:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionNone
                                                       changesBlock:^{
                                                           [self popToRootViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromLeft:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft
                                                       changesBlock:^{
                                                           [self popToRootViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromRight:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight
                                                       changesBlock:^{
                                                           [self popToRootViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlUp:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlUp
                                                       changesBlock:^{
                                                           [self popToRootViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlDown:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlDown
                                                       changesBlock:^{
                                                           [self popToRootViewControllerAnimated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFadeIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionFade subtype:nil
                                                   changesBlock:^{
                                                       [self popToRootViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionMoveIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionMoveIn subtype:subtype
                                                   changesBlock:^{
                                                       [self popToRootViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionPush:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionPush subtype:subtype
                                                   changesBlock:^{
                                                       [self popToRootViewControllerAnimated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionReveal:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionReveal subtype:subtype
                                                   changesBlock:^{
                                                       [self popToRootViewControllerAnimated:NO];
                                                   }];
                              break;}
                          default:{
                              break;}
                      }    
                  }
                  
                  - (void)popToViewController:(UIViewController *)viewController withCustomTransition:(CustomViewAnimationTransition)transition subtype:(NSString*)subtype {
                      switch (transition) {
                          case CustomViewAnimationTransitionNone:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionNone
                                                       changesBlock:^{
                                                           [self popToViewController:viewController animated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromLeft:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromLeft
                                                       changesBlock:^{
                                                           [self popToViewController:viewController animated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFlipFromRight:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionFlipFromRight
                                                       changesBlock:^{
                                                           [self popToViewController:viewController animated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlUp:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlUp
                                                       changesBlock:^{
                                                           [self popToViewController:viewController animated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionCurlDown:{
                              [self standardAnimationWithController:nil duration:.5 options:UIViewAnimationOptionTransitionCurlDown
                                                       changesBlock:^{
                                                           [self popToViewController:viewController animated:NO];
                                                       }];
                              break;}
                          case CustomViewAnimationTransitionFadeIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionFade subtype:nil
                                                   changesBlock:^{
                                                       [self popToViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionMoveIn:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionMoveIn subtype:subtype
                                                   changesBlock:^{
                                                       [self popToViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionPush:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionPush subtype:subtype
                                                   changesBlock:^{
                                                       [self popToViewController:viewController animated:NO];
                                                   }];
                              break;}
                          case CustomViewAnimationTransitionReveal:{
                              [self coreAnimationWithController:nil duration:.5 type:kCATransitionReveal subtype:subtype
                                                   changesBlock:^{
                                                       [self popToViewController:viewController animated:NO];
                                                   }];
                              break;}
                          default:{
                              break;}
                      }        
                  }
                  
                  #pragma mark -
                  #pragma mark private
                  
                  - (void)standardAnimationWithController:(UIViewController*)viewController
                                                  duration:(NSTimeInterval)duration
                                                  options:(UIViewAnimationOptions)options
                                                  changesBlock:(void (^)(void))block {
                      [UIView beginAnimations:nil context:NULL];
                      [UIView setAnimationDuration:duration];
                      [UIView transitionWithView:self.view duration:duration options:options animations:block completion:NULL];
                      [UIView commitAnimations];
                  }
                  
                  - (void)coreAnimationWithController:(UIViewController*)viewController
                                                  duration:(NSTimeInterval)duration
                                                  type:(NSString*)type
                                                  subtype:(NSString*)subtype
                                                  changesBlock:(void (^)(void))block {
                      CATransition* trans = [CATransition animation];
                      [trans setDuration:duration];
                      [trans setType:type];
                      [trans setSubtype:subtype];
                      [self.view.layer addAnimation:trans forKey:kCATransition];
                      block();
                  }
                  
                  @end
                  

                  这篇关于改变动画过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UINavigationController-Alike for Desktop-Cocoa? 下一篇:使用 hidesBottomBarWhenPushed 时,我希望标签栏在我推送另一个视图时重新出现

                  相关文章

                • <tfoot id='RLnQw'></tfoot>

                    <bdo id='RLnQw'></bdo><ul id='RLnQw'></ul>

                    <i id='RLnQw'><tr id='RLnQw'><dt id='RLnQw'><q id='RLnQw'><span id='RLnQw'><b id='RLnQw'><form id='RLnQw'><ins id='RLnQw'></ins><ul id='RLnQw'></ul><sub id='RLnQw'></sub></form><legend id='RLnQw'></legend><bdo id='RLnQw'><pre id='RLnQw'><center id='RLnQw'></center></pre></bdo></b><th id='RLnQw'></th></span></q></dt></tr></i><div id='RLnQw'><tfoot id='RLnQw'></tfoot><dl id='RLnQw'><fieldset id='RLnQw'></fieldset></dl></div>
                  1. <legend id='RLnQw'><style id='RLnQw'><dir id='RLnQw'><q id='RLnQw'></q></dir></style></legend>

                    <small id='RLnQw'></small><noframes id='RLnQw'>