diff --git a/AMWaveTransition/AMWaveTransition.h b/AMWaveTransition/AMWaveTransition.h index 6a6e458..b69966b 100644 --- a/AMWaveTransition/AMWaveTransition.h +++ b/AMWaveTransition/AMWaveTransition.h @@ -18,6 +18,11 @@ typedef NS_ENUM(NSInteger, AMWaveTransitionType) { AMWaveTransitionTypeBounce }; +typedef NS_ENUM(NSInteger, AMWaveInteractiveTransitionType) { + AMWaveTransitionEdgePan, + AMWaveTransitionFullScreenPan, +}; + @interface AMWaveTransition : NSObject /**----------------------------------------------------------------------------- @@ -107,4 +112,25 @@ typedef NS_ENUM(NSInteger, AMWaveTransitionType) { */ @property (assign, nonatomic) CGFloat maxDelay; +/** Inset between view controllers + * + * Sets the inset between view controllers. + * + */ +@property (assign, nonatomic) CGFloat viewControllersInset; + +/** Alpha animation with interactive transition + * + * Turn on/off alpha animation with interactive transition. + * + */ +@property (assign, nonatomic) BOOL animateAlphaWithInteractiveTransition; + +/** Interactive transition type + * + * Sets interactive transition type (edge or fullscreen). + * + */ +@property (assign, nonatomic) AMWaveInteractiveTransitionType interactiveTransitionType; + @end diff --git a/AMWaveTransition/AMWaveTransition.m b/AMWaveTransition/AMWaveTransition.m index 4542032..3d8719c 100644 --- a/AMWaveTransition/AMWaveTransition.m +++ b/AMWaveTransition/AMWaveTransition.m @@ -8,12 +8,18 @@ #import "AMWaveTransition.h" +typedef NS_ENUM(NSInteger, AMWaveTransitionViewControllers) { + AMWaveTransitionToVC, + AMWaveTransitionFromVC, +}; + @interface AMWaveTransition () -@property (nonatomic, strong) UIScreenEdgePanGestureRecognizer *gesture; +@property (nonatomic, strong) UIGestureRecognizer *gesture; @property (nonatomic, weak) UINavigationController *navigationController; @property (nonatomic, assign) int selectionIndexFrom; @property (nonatomic, assign) int selectionIndexTo; +@property (nonatomic, assign) CGPoint firstTouch; @property (nonatomic, strong) UIDynamicAnimator *animator; @property (nonatomic, strong) NSMutableArray *attachmentsFrom; @@ -21,12 +27,13 @@ @interface AMWaveTransition () @end + @implementation AMWaveTransition #define SCREEN_WIDTH ((([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) || ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height) -#define DURATION 0.65 -#define MAX_DELAY 0.15 +const CGFloat DURATION = 0.65; +const CGFloat MAX_DELAY = 0.15; - (instancetype)init { @@ -67,6 +74,9 @@ - (instancetype)initWithOperation:(UINavigationControllerOperation)operation and - (void)setup { + _viewControllersInset = 20; + _interactiveTransitionType = AMWaveTransitionFullScreenPan; + _animateAlphaWithInteractiveTransition = YES; _duration = DURATION; _maxDelay = MAX_DELAY; } @@ -74,10 +84,19 @@ - (void)setup - (void)attachInteractiveGestureToNavigationController:(UINavigationController *)navigationController { self.navigationController = navigationController; - self.gesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)]; - [self.gesture setEdges:UIRectEdgeLeft]; + if (self.interactiveTransitionType == AMWaveTransitionEdgePan) { + + UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] + initWithTarget:self + action:@selector(handlePan:)]; + [recognizer setEdges:UIRectEdgeLeft]; + self.gesture = recognizer; + } else { + UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self + action:@selector(handlePan:)]; + self.gesture = recognizer; + } [navigationController.view addGestureRecognizer:self.gesture]; - self.animator = [[UIDynamicAnimator alloc]initWithReferenceView:navigationController.view]; self.attachmentsFrom = [@[] mutableCopy]; self.attachmentsTo = [@[] mutableCopy]; @@ -92,6 +111,8 @@ - (void)detachInteractiveGesture self.animator = nil; } +#pragma mark - Interactive Transition + - (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture { // Starting controller @@ -101,72 +122,95 @@ - (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture // Controller that will be visible after the pop UIViewController *toVC; int index = (int)[self.navigationController.viewControllers indexOfObject:self.navigationController.topViewController]; - toVC = (UIViewController *)self.navigationController.viewControllers[index-1]; - // The gesture velocity will also determine the velocity of the cells float velocity = [gesture velocityInView:self.navigationController.view].x; CGPoint touch = [gesture locationInView:self.navigationController.view]; + if (index == 0) { + //simple attach animation instead of crash + touch.x = 0; + toVC = nil; + } else { + toVC = (UIViewController *)self.navigationController.viewControllers[index-1]; + } if (gesture.state == UIGestureRecognizerStateBegan) { - [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - // The 'selected' cell will be the one leading the other cells - if (CGRectContainsPoint([view.superview convertRect:view.frame toView:nil], touch)) { - self.selectionIndexFrom = (int)idx; - } - UIAttachmentBehavior *attachment = [[UIAttachmentBehavior alloc] initWithItem:view - attachedToAnchor:(CGPoint){touch.x, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; - [attachment setDamping:0.4]; - [attachment setFrequency:1]; - [self.animator addBehavior:attachment]; - [self.attachmentsFrom addObject:attachment]; - }]; - - + if (self.interactiveTransitionType == AMWaveTransitionFullScreenPan) { + self.firstTouch = touch; + } else { + self.firstTouch = CGPointMake(0, 0); + } + if ([fromVC respondsToSelector:@selector(visibleCells)] && [fromVC visibleCells].count > 0) { + [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + // The 'selected' cell will be the one leading the other cells + if (CGRectContainsPoint([view.superview convertRect:view.frame toView:nil], touch)) { + self.selectionIndexFrom = (int)idx; + } + [self createAttachmentForView:view inVC:AMWaveTransitionFromVC]; + }]; + } else { + UIView *view = fromVC.view; + self.selectionIndexFrom = 0; + [self createAttachmentForView:view inVC:AMWaveTransitionFromVC]; + } // Kick the 'new' cells outside the view - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = -SCREEN_WIDTH; - if (self.navigationController.navigationBar.translucent) { - rect.origin.y += self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height; - } - view.frame = rect; - }]; - - [self.navigationController.view addSubview:toVC.view]; - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect futureRect = view.frame; - futureRect.origin.x = 0; - if (CGRectContainsPoint([view.superview convertRect:futureRect toView:nil], touch)) { - self.selectionIndexTo = (int)idx; - } - // TODO: move the setalpha below and scale it - [view setAlpha:1]; - UIAttachmentBehavior *attachment = [[UIAttachmentBehavior alloc] initWithItem:view attachedToAnchor:(CGPoint){touch.x, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; - [attachment setDamping:0.4]; - [attachment setFrequency:1]; - [self.animator addBehavior:attachment]; - [self.attachmentsTo addObject:attachment]; - }]; + [self.navigationController.view insertSubview:toVC.view belowSubview:self.navigationController.navigationBar]; + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self kickCellOutside:view]; + }]; + } else if (toVC) { + UIView *view = toVC.view; + [self kickCellOutside:view]; + } + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + CGRect futureRect = view.frame; + futureRect.origin.x = 0; + if (CGRectContainsPoint([view.superview convertRect:futureRect toView:nil], touch)) { + self.selectionIndexTo = (int)idx; + } + [self createAttachmentForView:view inVC:AMWaveTransitionToVC]; + }]; + } else if (toVC) { + UIView *view = toVC.view; + self.selectionIndexTo = 0; + [self createAttachmentForView:view inVC:AMWaveTransitionToVC]; + + } } else if (gesture.state == UIGestureRecognizerStateChanged) { - - [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - float delta = touch.x - abs(self.selectionIndexFrom - (int)idx) * velocity / 50; - // Prevent the anchor point from going 'over' the cell - if (delta > view.frame.origin.x + view.frame.size.width / 2) { - delta = view.frame.origin.x + view.frame.size.width / 2 - 2; - } - [self.attachmentsFrom[idx] setAnchorPoint:(CGPoint){delta, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; - }]; - - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - float delta = [gesture locationInView:self.navigationController.view].x - abs(self.selectionIndexTo - (int)idx) * velocity / 50; - // Prevent the anchor point from going 'over' the cell - if (delta < view.frame.origin.x + view.frame.size.width / 2) { - delta = view.frame.origin.x + view.frame.size.width / 2 + 2; - } - [self.attachmentsTo[idx] setAnchorPoint:(CGPoint){delta, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; - }]; + if ([fromVC respondsToSelector:@selector(visibleCells)] && [fromVC visibleCells].count > 0) { + [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self changeAttachmentWithIndex:idx + inView:view + touchX:touch.x + velocity:velocity + inVC:AMWaveTransitionFromVC]; + }]; + } else { + UIView *view = fromVC.view; + [self changeAttachmentWithIndex:0 + inView:view + touchX:touch.x + velocity:velocity + inVC:AMWaveTransitionFromVC]; + } + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self changeAttachmentWithIndex:idx + inView:view + touchX:touch.x + velocity:velocity + inVC:AMWaveTransitionToVC]; + }]; + } else if (toVC) { + UIView *view = toVC.view; + [self changeAttachmentWithIndex:0 + inView:view + touchX:touch.x + velocity:velocity + inVC:AMWaveTransitionToVC]; + } } else if (gesture.state == UIGestureRecognizerStateEnded || gesture.state == UIGestureRecognizerStateCancelled) { [self.attachmentsFrom enumerateObjectsUsingBlock:^(UIAttachmentBehavior *obj, NSUInteger idx, BOOL *stop) { @@ -182,56 +226,174 @@ - (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture if (gesture.state == UIGestureRecognizerStateEnded && touch.x > self.navigationController.view.frame.size.width * 0.7) { // Complete the transition [UIView animateWithDuration:0.3 animations:^{ - [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = SCREEN_WIDTH; - view.frame = rect; - }]; - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = 0; - view.frame = rect; - }]; - } completion:^(BOOL finished) { - if (self.navigationController.navigationBar.translucent) { + if ([fromVC respondsToSelector:@selector(visibleCells)] && [fromVC visibleCells].count > 0) { + [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self completeFromVC:view]; + }]; + } else { + UIView *view = fromVC.view; + [self completeFromVC:view]; + } + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.y -= self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height; - view.frame = rect; + [self setPresentedFrameForView:view]; }]; + } else { + UIView *view = toVC.view; + [self setPresentedFrameForView:view]; } + } completion:^(BOOL finished) { + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self animationCompletionForInteractiveTransitionForView:view]; + }]; + } else { + UIView *view = toVC.view; + [self animationCompletionForInteractiveTransitionForView:view]; + } + [self.navigationController popViewControllerAnimated:NO]; }]; } else { // Abort [UIView animateWithDuration:0.3 animations:^{ - [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = 0; - view.frame = rect; - }]; - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = -SCREEN_WIDTH; - view.frame = rect; - }]; + if ([fromVC respondsToSelector:@selector(visibleCells)] && [fromVC visibleCells].count > 0) { + [[fromVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self setPresentedFrameForView:view]; + }]; + } else { + UIView *view = fromVC.view; + [self setPresentedFrameForView:view]; + } + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self completeToVC:view]; + }]; + } else { + UIView *view = toVC.view; + [self completeFromVC:view]; + } } completion:^(BOOL finished) { // Bring 'silently' the cell back to their place, or the normal pop operation would fail - [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { - CGRect rect = view.frame; - rect.origin.x = 0; - if (self.navigationController.navigationBar.translucent) { - rect.origin.y -= self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height; - } - view.frame = rect; - }]; + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { + [[toVC visibleCells] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { + [self animationCompletionForInteractiveTransitionForView:view]; + }]; + } else { + UIView *view = toVC.view; + [self animationCompletionForInteractiveTransitionForView:view]; + } [toVC.view removeFromSuperview]; }]; - } } } +- (void)animationCompletionForInteractiveTransitionForView:(UIView *)view { + CGRect rect = view.frame; + rect.origin.x = 0; + if (self.navigationController.navigationBar.translucent && !self.navigationController.navigationBar.hidden) { + rect.origin.y -= self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height; + } + view.frame = rect; + view.alpha = [self alphaForView:view]; +} + + +- (void)setPresentedFrameForView:(UIView *)view { + CGRect rect = view.frame; + rect.origin.x = 0; + view.frame = rect; + view.alpha = [self alphaForView:view]; +} + +- (void)kickCellOutside:(UIView *)view { + CGRect rect = view.frame; + rect.origin.x = -SCREEN_WIDTH - self.viewControllersInset; + if (self.navigationController.navigationBar.translucent) { + rect.origin.y += self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height; + } + view.alpha = [self alphaForView:view]; + view.frame = rect; +} + +- (void)completeToVC:(UIView *)view { + [self completeTransitionWithView:view inVC:AMWaveTransitionToVC]; +} + +- (void)completeFromVC:(UIView *)view { + [self completeTransitionWithView:view inVC:AMWaveTransitionFromVC]; +} + +- (void)completeTransitionWithView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController { + CGRect rect = view.frame; + if (viewController == AMWaveTransitionFromVC) { + rect.origin.x = SCREEN_WIDTH - self.viewControllersInset; + } else { + rect.origin.x = -SCREEN_WIDTH - self.viewControllersInset; + } + view.frame = rect; + view.alpha = [self alphaForView:view]; +} + +- (void)changeAttachmentWithIndex:(NSUInteger)index + inView:(UIView *)view + touchX:(CGFloat)touchX + velocity:(CGFloat)velocity + inVC:(AMWaveTransitionViewControllers)viewController { + int selectionIndex; + NSInteger correction = 2; + NSMutableArray *arrayWithAttachments; + if (viewController == AMWaveTransitionToVC) { + arrayWithAttachments = self.attachmentsTo; + selectionIndex = self.selectionIndexTo; + } else { + arrayWithAttachments = self.attachmentsFrom; + selectionIndex = self.selectionIndexFrom; + correction = -correction; + } + + float delta = touchX - self.firstTouch.x - abs(selectionIndex - (int)index) * velocity / 50; + // Prevent the anchor point from going 'over' the cell + if (delta > view.frame.origin.x + view.frame.size.width / 2 && viewController == AMWaveTransitionFromVC) { + delta = view.frame.origin.x + view.frame.size.width / 2 + correction; + } else if (delta < view.frame.origin.x + view.frame.size.width / 2 && viewController == AMWaveTransitionToVC) { + delta = view.frame.origin.x + view.frame.size.width / 2 + correction; + } + view.alpha = [self alphaForView:view]; + [arrayWithAttachments[index] setAnchorPoint:(CGPoint){delta, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; +} + +- (void)createAttachmentForView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController { + UIAttachmentBehavior *attachment = [[UIAttachmentBehavior alloc] initWithItem:view attachedToAnchor:(CGPoint){0, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}]; + [attachment setDamping:0.4]; + [attachment setFrequency:1]; + [self.animator addBehavior:attachment]; + view.alpha = [self alphaForView:view]; + + NSMutableArray *arrayWithAttachments; + if (viewController == AMWaveTransitionToVC) { + arrayWithAttachments = self.attachmentsTo; + } else { + arrayWithAttachments = self.attachmentsFrom; + } + + [arrayWithAttachments addObject:attachment]; +} + +- (CGFloat)alphaForView:(UIView *)view { + if (self.animateAlphaWithInteractiveTransition) { + CGFloat width = SCREEN_WIDTH - self.viewControllersInset; + CGFloat alpha =(width - fabs(view.frame.origin.x)) * (1 / width); + return alpha; + } else { + return 1.0; + } +} + +#pragma mark - Non interactive transition + - (NSTimeInterval)transitionDuration:(id )transitionContext { return self.duration + self.maxDelay; @@ -257,16 +419,15 @@ - (void)animateTransition:(id )transitionC CGFloat delta; if (self.operation == UINavigationControllerOperationPush) { - delta = SCREEN_WIDTH; + delta = SCREEN_WIDTH + self.viewControllersInset; } else { - - delta = -SCREEN_WIDTH; + delta = -SCREEN_WIDTH - self.viewControllersInset; } // Move the destination in place toVC.view.frame = [transitionContext finalFrameForViewController:toVC]; // And kick it aside - toVC.view.transform = CGAffineTransformMakeTranslation(SCREEN_WIDTH, 0); + toVC.view.transform = CGAffineTransformMakeTranslation(delta, 0); // First step is required to trigger the load of the visible cells. [UIView animateWithDuration:0 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:nil completion:^(BOOL done) { @@ -283,15 +444,15 @@ - (void)animateTransition:(id )transitionC [fromVC.view setTransform:CGAffineTransformMakeTranslation(1, 0)]; [toVC.view setTransform:CGAffineTransformIdentity]; [UIView animateWithDuration:self.duration + self.maxDelay delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ - [fromVC.view setTransform:CGAffineTransformMakeTranslation(SCREEN_WIDTH, 0)]; + [fromVC.view setTransform:CGAffineTransformMakeTranslation(delta, 0)]; } completion:^(BOOL finished) { + [fromVC.view removeFromSuperview]; [transitionContext completeTransition:YES]; - [fromVC.view removeFromSuperview]; }]; } // Animates the cells of the starting view controller - if ([fromVC respondsToSelector:@selector(visibleCells)]) { + if ([fromVC respondsToSelector:@selector(visibleCells)] && [fromVC visibleCells].count > 0) { [[fromVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) { NSTimeInterval delay = ((float)idx / (float)[[fromVC visibleCells] count]) * self.maxDelay; [self hideView:obj withDelay:delay andDelta:-delta]; @@ -301,7 +462,7 @@ - (void)animateTransition:(id )transitionC [self hideView:fromVC.view withDelay:0 andDelta:-delta]; } - if ([toVC respondsToSelector:@selector(visibleCells)]) { + if ([toVC respondsToSelector:@selector(visibleCells)] && [toVC visibleCells].count > 0) { [[toVC visibleCells] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) { NSTimeInterval delay = ((float)idx / (float)[[toVC visibleCells] count]) * self.maxDelay; [self presentView:obj withDelay:delay andDelta:delta]; @@ -316,7 +477,7 @@ - (void)hideView:(UIView *)view withDelay:(NSTimeInterval)delay andDelta:(float) { void (^animation)() = ^{ [view setTransform:CGAffineTransformMakeTranslation(delta, 0)]; - [view setAlpha:0]; + [view setAlpha:0]; }; void (^completion)(BOOL) = ^(BOOL finished){ [view setTransform:CGAffineTransformIdentity]; @@ -335,7 +496,7 @@ - (void)presentView:(UIView *)view withDelay:(NSTimeInterval)delay andDelta:(flo [view setTransform:CGAffineTransformMakeTranslation(delta, 0)]; void (^animation)() = ^{ [view setTransform:CGAffineTransformIdentity]; - [view setAlpha:1]; + [view setAlpha:1]; }; if (self.transitionType == AMWaveTransitionTypeSubtle) { [UIView animateWithDuration:self.duration delay:delay options:UIViewAnimationOptionCurveEaseIn animations:animation completion:nil]; diff --git a/Demo/Demo/Base.lproj/Main.storyboard b/Demo/Demo/Base.lproj/Main.storyboard index 894c32f..0d4c20e 100644 --- a/Demo/Demo/Base.lproj/Main.storyboard +++ b/Demo/Demo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -9,14 +9,14 @@ - - + + - + @@ -53,12 +53,6 @@ - - - - - - @@ -74,14 +68,14 @@ - - + + - + @@ -125,12 +119,6 @@ - - - - - - @@ -146,14 +134,14 @@ - - + + - - - - - @@ -197,8 +181,8 @@ - - + + diff --git a/Demo/Demo/FourthViewController.m b/Demo/Demo/FourthViewController.m index 5fe4f8c..26cf56e 100644 --- a/Demo/Demo/FourthViewController.m +++ b/Demo/Demo/FourthViewController.m @@ -7,9 +7,10 @@ // #import "FourthViewController.h" +#import "AMWaveTransition.h" @interface FourthViewController () - +@property (strong, nonatomic) IBOutlet AMWaveTransition *interactive; @end @implementation FourthViewController @@ -17,7 +18,22 @@ @implementation FourthViewController - (void)viewDidLoad { [super viewDidLoad]; + [self.view setBackgroundColor:[UIColor clearColor]]; + + _interactive = [[AMWaveTransition alloc] init]; +} + +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + [self.interactive attachInteractiveGestureToNavigationController:self.navigationController]; +} + +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + [self.interactive detachInteractiveGesture]; } @end diff --git a/Demo/Demo/ThirdViewController.m b/Demo/Demo/ThirdViewController.m index c6c2149..7f17083 100644 --- a/Demo/Demo/ThirdViewController.m +++ b/Demo/Demo/ThirdViewController.m @@ -15,6 +15,7 @@ @interface ThirdViewController ()