Skip to content

Instantly share code, notes, and snippets.

@BradB132
BradB132 / TTBaseAnimator.h
Created June 10, 2015 16:43
ViewControllerTransitionsPart3-6
@interface TTBaseAnimator : NSObject
@property (nonatomic) NSTimeInterval duration;
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning> )transitionContext;
@end
@BradB132
BradB132 / TTPushController.m
Last active August 29, 2015 14:22
ViewControllerTransitionsPart3-5
@interface TTPushController ()
@property (nonatomic, strong) TTInteractivePinchTransition* transition;
@property (nonatomic, strong) UIPinchGestureRecognizer* pinch;
@end
// ...
- (void)viewDidLoad
@BradB132
BradB132 / TTInteractivePinchTransition.h
Created June 10, 2015 16:39
ViewControllerTransitionsPart3-4
@protocol TTInteractivePinchTransitionDelegate <NSObject>
-(void)delegateShouldPerformSegue:(TTInteractivePinchTransition*)transition
pinch:(UIPinchGestureRecognizer*)pinch;
@end
@interface TTInteractivePinchTransition : UIPercentDrivenInteractiveTransition
@property (nonatomic, weak) id<TTInteractivePinchTransitionDelegate> delegate;
-(void)handlePinch:(UIPinchGestureRecognizer*)pinch;
@BradB132
BradB132 / TTNavigationController.m
Last active August 29, 2015 14:22
ViewControllerTransitionsPart3-3
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController
{
if([_mostRecentController respondsToSelector:@selector(navigationController:interactionControllerForAnimationController:)])
{
return [(id<UINavigationControllerDelegate>)_mostRecentController navigationController:navigationController
interactionControllerForAnimationController:animationController];
}
return nil;
}
@BradB132
BradB132 / TTNavigationController.m
Last active August 29, 2015 14:22
ViewControllerTransitionsPart3-2
@interface TTNavigationController ()
@property (nonatomic, weak) UIViewController* mostRecentController;
@end
// ...
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
@BradB132
BradB132 / TTNavigationController.m
Last active August 29, 2015 14:22
ViewControllerTransitionsPart3-1
- (void)viewDidLoad
{
[super viewDidLoad];
self.delegate = self;
}
@BradB132
BradB132 / TTPushAnimator.m
Created June 10, 2015 05:18
ViewControllerTransitionsPart2-8
fromController.view.hidden = YES;
@BradB132
BradB132 / TTPushAnimator.m
Created June 10, 2015 05:17
ViewControllerTransitionsPart2-7
[fromController.view removeFromSuperview];
@BradB132
BradB132 / TTPushAnimator.m
Created June 10, 2015 05:15
ViewControllerTransitionsPart2-6
//remove this line
//[transitionContext completeTransition:finished];
//use this code instead:
//put the original stuff back in place if the user cancelled
if(transitionContext.transitionWasCancelled)
{
[toController.view removeFromSuperview];
[container addSubview:fromController.view];
@BradB132
BradB132 / TTViewController.m
Created June 10, 2015 05:08
ViewControllerTransitionsPart2-5
#pragma mark - UINavigationControllerDelegate
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController
{
if([animationController isKindOfClass:[TTPushAnimator class]])
return _transition;
return nil;
}