This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(float)percentForPinch:(UIPinchGestureRecognizer*)pinch | |
{ | |
return (pinch.scale - 1.0f)/2.0f;//denominator is just a fudge factor to get the 'feel' right | |
} | |
-(void)handlePinch:(UIPinchGestureRecognizer*)pinch | |
{ | |
switch (pinch.state) | |
{ | |
case UIGestureRecognizerStateBegan: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; | |
[self.view addGestureRecognizer:_pinch]; | |
self.transition = [[UIPercentDrivenInteractiveTransition alloc] init]; | |
self.navigationController.delegate = self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic, strong) UIPercentDrivenInteractiveTransition* transition; | |
@property (nonatomic, strong) UIPinchGestureRecognizer* pinch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext | |
{ | |
UIViewController* toController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | |
UIViewController* fromController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | |
UIView* container = [transitionContext containerView]; | |
//get rects that represent the top and bottom halves of the screen | |
CGSize viewSize = fromController.view.bounds.size; | |
CGRect topFrame = CGRectMake(0, 0, viewSize.width, viewSize.height/2); | |
CGRect bottomFrame = CGRectMake(0, viewSize.height/2, viewSize.width, viewSize.height/2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext | |
{ | |
UIViewController* toController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; | |
UIViewController* fromController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; | |
UIView* container = [transitionContext containerView]; | |
//get rects that represent the top and bottom halves of the screen | |
CGSize viewSize = fromController.view.bounds.size; | |
CGRect topFrame = CGRectMake(0, 0, viewSize.width, viewSize.height/2); | |
CGRect bottomFrame = CGRectMake(0, viewSize.height/2, viewSize.width, viewSize.height/2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - UINavigationControllerDelegate | |
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController | |
animationControllerForOperation:(UINavigationControllerOperation)operation | |
fromViewController:(UIViewController *)fromVC | |
toViewController:(UIViewController *)toVC | |
{ | |
switch(operation) | |
{ | |
case UINavigationControllerOperationPush: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define kTransitionDuration 0.35 | |
// ... | |
#pragma mark - UIViewControllerAnimatedTransitioning | |
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext | |
{ | |
return kTransitionDuration; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - UINavigationControllerDelegate | |
- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController | |
animationControllerForOperation:(UINavigationControllerOperation)operation | |
fromViewController:(UIViewController *)fromVC | |
toViewController:(UIViewController *)toVC | |
{ | |
return [[TTFadeAnimator alloc] init]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.navigationController.delegate = self; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(application: UIApplication, _: [NSObject: AnyObject]?) -> Bool { | |
//we don't care about launch options | |
return true | |
} |