react-native-navigation的迁移库

RNNPushAnimation.m 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. #import "RNNPushAnimation.h"
  2. @implementation RNNPushAnimation
  3. - (instancetype)initWithScreenTransition:(RNNScreenTransition *)screenTransition {
  4. self = [super init];
  5. self.screenTransition = screenTransition;
  6. return self;
  7. }
  8. - (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
  9. return 0.5;
  10. }
  11. - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
  12. UIViewController* toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  13. [[transitionContext containerView] addSubview:toViewController.view];
  14. [self.screenTransition.content setupInitialTransitionForView:toViewController.view];
  15. [self.screenTransition.topBar setupInitialTransitionForView:toViewController.navigationController.navigationBar];
  16. [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
  17. [self.screenTransition.content completeTransitionForView:toViewController.view];
  18. [self.screenTransition.topBar completeTransitionForView:toViewController.navigationController.navigationBar];
  19. } completion:^(BOOL finished) {
  20. [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
  21. }];
  22. }
  23. @end