CWLateralSlideAnimator.m 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // CWLateralSlideAnimator.m
  3. // ViewControllerTransition
  4. //
  5. // Created by chavez on 2017/6/29.
  6. // Copyright © 2017年 chavez. All rights reserved.
  7. //
  8. #import "CWLateralSlideAnimator.h"
  9. #import "CWDrawerTransition.h"
  10. @interface CWLateralSlideAnimator ()
  11. @property (nonatomic,strong) CWInteractiveTransition *interactiveHidden;
  12. @property (nonatomic,strong) CWInteractiveTransition *interactiveShow;
  13. @end
  14. @implementation CWLateralSlideAnimator
  15. - (instancetype)initWithConfiguration:(CWLateralSlideConfiguration *)configuration {
  16. if (self = [super init]) {
  17. _configuration = configuration;
  18. }
  19. return self;
  20. }
  21. + (instancetype)lateralSlideAnimatorWithConfiguration:(CWLateralSlideConfiguration *)configuration {
  22. return [[self alloc] initWithConfiguration:configuration];
  23. }
  24. - (void)dealloc {
  25. // NSLog(@"%s",__func__);
  26. }
  27. - (void)setConfiguration:(CWLateralSlideConfiguration *)configuration {
  28. _configuration = configuration;
  29. [self.interactiveShow setValue:configuration forKey:@"configuration"];
  30. [self.interactiveHidden setValue:configuration forKey:@"configuration"];
  31. }
  32. #pragma mark -UIViewControllerTransitioningDelegate
  33. - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
  34. return [CWDrawerTransition transitionWithType:CWDrawerTransitiontypeShow animationType:_animationType configuration:_configuration];
  35. }
  36. - (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
  37. return [CWDrawerTransition transitionWithType:CWDrawerTransitiontypeHidden animationType:_animationType configuration:_configuration];
  38. }
  39. - (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator {
  40. return self.interactiveShow.interacting ? self.interactiveShow : nil;
  41. }
  42. - (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator {
  43. // NSLog(@"----------------------%@",self.interactiveHidden);
  44. return self.interactiveHidden.interacting ? self.interactiveHidden : nil;
  45. }
  46. @end