Skip to content

Instantly share code, notes, and snippets.

@clooth
Created September 27, 2013 19:24
Show Gist options
  • Save clooth/6733903 to your computer and use it in GitHub Desktop.
Save clooth/6733903 to your computer and use it in GitHub Desktop.
segue
//
// HorizontalSlideSegue.m
// YouLapse
//
// Created by Nico Hämäläinen on 9/27/13.
// Copyright (c) 2013 YouLapse Oy. All rights reserved.
//
#import "HorizontalSlidePushSegue.h"
@implementation HorizontalSlidePushSegue
- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
{
if (self = [super initWithIdentifier:identifier source:source destination:destination]) {
_isUnwinding = NO;
}
return self;
}
- (void)perform
{
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.type = kCATransitionPush;
if (_isUnwinding == YES) {
transition.subtype = kCATransitionFromLeft;
[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController popToViewController:destinationController animated:NO];
} else {
transition.subtype = kCATransitionFromRight;
[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment