@@ -104,37 +104,52 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
104104 if ([fromVC respondsToSelector: @selector (visibleCells )]) {
105105 [[fromVC visibleCells ] enumerateObjectsWithOptions: NSEnumerationReverse usingBlock: ^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
106106 NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * self.maxDelay ;
107- void (^animation)() = ^{
108- [obj setTransform: CGAffineTransformMakeTranslation (-delta, 0 )];
109- [obj setAlpha: 0 ];
110- };
111- void (^completion)(BOOL ) = ^(BOOL finished){
112- [obj setTransform: CGAffineTransformIdentity];
113- };
114- if (self.transitionType == AMWaveTransitionTypeSubtle) {
115- [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
116- } else {
117- [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
118- }
107+ [self hideView: obj withDelay: delay andDelta: -delta];
119108 }];
109+ } else {
110+ // The controller has no table view, let's animate it gracefully
111+ [self hideView: fromVC.view withDelay: 0 andDelta: -delta];
120112 }
121-
113+
122114 if ([toVC respondsToSelector: @selector (visibleCells )]) {
123115 [[toVC visibleCells ] enumerateObjectsWithOptions: NSEnumerationReverse usingBlock: ^(UITableViewCell *obj, NSUInteger idx, BOOL *stop) {
124- NSTimeInterval delay = ((float )idx / (float )[[fromVC visibleCells ] count ]) * self.maxDelay ;
125- [obj setTransform: CGAffineTransformMakeTranslation (delta, 0 )];
126- void (^animation)() = ^{
127- [obj setTransform: CGAffineTransformIdentity];
128- [obj setAlpha: 1 ];
129- };
130- if (self.transitionType == AMWaveTransitionTypeSubtle) {
131- [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
132- } else {
133- [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
134- }
116+ NSTimeInterval delay = ((float )idx / (float )[[toVC visibleCells ] count ]) * self.maxDelay ;
117+ [self presentView: obj withDelay: delay andDelta: delta];
135118 }];
119+ } else {
120+ [self presentView: toVC.view withDelay: 0 andDelta: delta];
136121 }
137122 }];
138123}
139124
125+ - (void )hideView : (UIView *)view withDelay : (NSTimeInterval )delay andDelta : (float )delta
126+ {
127+ void (^animation)() = ^{
128+ [view setTransform: CGAffineTransformMakeTranslation (delta, 0 )];
129+ [view setAlpha: 0 ];
130+ };
131+ void (^completion)(BOOL ) = ^(BOOL finished){
132+ [view setTransform: CGAffineTransformIdentity];
133+ };
134+ if (self.transitionType == AMWaveTransitionTypeSubtle) {
135+ [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
136+ } else {
137+ [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: completion];
138+ }
139+ }
140+
141+ - (void )presentView : (UIView *)view withDelay : (NSTimeInterval )delay andDelta : (float )delta
142+ {
143+ [view setTransform: CGAffineTransformMakeTranslation (delta, 0 )];
144+ void (^animation)() = ^{
145+ [view setTransform: CGAffineTransformIdentity];
146+ [view setAlpha: 1 ];
147+ };
148+ if (self.transitionType == AMWaveTransitionTypeSubtle) {
149+ [UIView animateWithDuration: self .duration delay: delay options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
150+ } else {
151+ [UIView animateWithDuration: self .duration delay: delay usingSpringWithDamping: 0.75 initialSpringVelocity: 1 options: UIViewAnimationOptionCurveEaseIn animations: animation completion: nil ];
152+ }
153+ }
154+
140155@end
0 commit comments