diff --git a/Example/Example/ModalTransitionContrlller/TLModalMenuController.m b/Example/Example/ModalTransitionContrlller/TLModalMenuController.m index 609d91e..34005ca 100644 --- a/Example/Example/ModalTransitionContrlller/TLModalMenuController.m +++ b/Example/Example/ModalTransitionContrlller/TLModalMenuController.m @@ -40,6 +40,9 @@ - (void)viewDidLoad { self.tableView.tableFooterView = [UIView new]; self.automaticallyAdjustsScrollViewInsets = YES; + + + [self testRegisterInteractiveTransition]; } - (void)viewDidAppear:(BOOL)animated { @@ -49,6 +52,29 @@ - (void)viewDidAppear:(BOOL)animated { self.tabBarController.tabBar.hidden = NO; } +- (void)testRegisterInteractiveTransition { + UIViewController *vc = [[UIViewController alloc] init]; + CAGradientLayer *gradient = [CAGradientLayer layer]; + gradient.frame = vc.view.bounds; + gradient.colors = [NSArray arrayWithObjects: + (id)[UIColor redColor].CGColor, + (id)[UIColor greenColor].CGColor, + (id)[UIColor blueColor].CGColor, nil]; + gradient.startPoint = CGPointMake(0, 0); + gradient.endPoint = CGPointMake(1, 1); + gradient.locations = @[@0.0, @0.5, @1.0]; + [vc.view.layer addSublayer:gradient]; + + // 注册手势 + TLSwipeAnimator *animator = [TLSwipeAnimator animatorWithSwipeType:TLSwipeTypeInAndOut pushDirection:TLDirectionToLeft popDirection:TLDirectionToRight]; + animator.transitionDuration = 0.35f; + // 必须初始化的属性 + animator.isPushOrPop = NO; + animator.interactiveDirectionOfPush = TLDirectionToLeft; + + [self registerInteractiveTransitionToViewController:vc animator:animator]; +} + #pragma mark - Table view data source and delegate - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { diff --git a/README.md b/README.md index 22e078f..4833554 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ### pod支持 ##### 1. 版本 ``` -pod 'TLTransitions', '~> 1.4.7' +pod 'TLTransitions', '~> 1.5.0' ``` ##### 2. CocoaPods获取不到最新的`TLTransitions`版本问题 diff --git a/TLTransitions.podspec b/TLTransitions.podspec index e0bfe42..c091ed3 100644 --- a/TLTransitions.podspec +++ b/TLTransitions.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'TLTransitions' - s.version = '1.4.9' + s.version = '1.5.0' s.license = 'MIT' s.ios.deployment_target = '8.0' s.platform = :ios, '8.0' diff --git a/TLTransitions/TransitionController/UIViewController+Transitioning.h b/TLTransitions/TransitionController/UIViewController+Transitioning.h index adb25ad..4b237db 100644 --- a/TLTransitions/TransitionController/UIViewController+Transitioning.h +++ b/TLTransitions/TransitionController/UIViewController+Transitioning.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN /// 转场动画(面向present/push To View Controller) @property(nonatomic, weak, readonly) TLTransitionDelegate *transitionDelegate; - +/// 注册push/present手势后,要转场的控制器 @property(nonatomic, weak, readonly) UIViewController *willPresentViewController; /** 侧滑pop/dismiss交互手势启用开关。默认开启(NO) @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN // NOTE:下面不同类型的Animator实现的转场效果有些类似,只是实现方案有所差异 /** * present 转场控制器。 - * @param viewController 要转场的控制器 + * @param viewController 要转场的控制器 对应 willPresentViewController 属性 * @param animator 转场动画管理对象 * 目前提供“TLSystemAnimator”、“TLSwipeAnimator”、“TLCATransitionAnimator”、“TLCuStomAnimator” 、 “TLAnimator”供选择, * 也可以由开发者自己写一个这样的对象,需要 严格遵守 TLAnimatorProtocal协议(可以参考模版TLAnimatorTemplate) diff --git a/TLTransitions/TransitionController/UIViewController+Transitioning.m b/TLTransitions/TransitionController/UIViewController+Transitioning.m index 631e431..94875f7 100644 --- a/TLTransitions/TransitionController/UIViewController+Transitioning.m +++ b/TLTransitions/TransitionController/UIViewController+Transitioning.m @@ -118,7 +118,7 @@ - (void)registerInteractiveTransitionToViewController:(UIViewController *)viewCo - (void)interactivePushRecognizerAction:(UIPanGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { - if (self.transitionDelegate == nil) { + if (self.willPresentViewController.transitionDelegate == nil) { return; }