Custom Transitions in iOS7 by Leszek Kaczor

13

description

Custom Transitions by Leszek Kaczor during the Untitled Kingdom Event in Pauza In Garden/ Kraków, Poland

Transcript of Custom Transitions in iOS7 by Leszek Kaczor

Page 1: Custom Transitions in iOS7 by Leszek Kaczor
Page 2: Custom Transitions in iOS7 by Leszek Kaczor

Custom transitionsUntitled Kingdom Ltd

Leszek Kaczor

Page 3: Custom Transitions in iOS7 by Leszek Kaczor

Przebieg prezentacji

• Nowe metody do tworzenia animacji • spring animations • keyframe animations

• Przejścia pomiędzy widokami • animacyjne (custom transitions) • interaktywne (interactive transitions)

Page 4: Custom Transitions in iOS7 by Leszek Kaczor

Animacje• Podstawowa metoda tworzenia animacji:

[UIView beginAnimations:nil context:NULL];[UIView setAnimationDuration:2.0f];[UIView setAnimationDelegate:self];[UIView setAnimationDidStopSelector:@selector(fadeIn:finished:context:)];[view setAlpha:0.0f];[UIView commitAnimations]; !

• Od wersji iOS4: + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Page 5: Custom Transitions in iOS7 by Leszek Kaczor

Animacje

• Spring animations

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

Page 6: Custom Transitions in iOS7 by Leszek Kaczor

Animacje

• Keyframe animations

+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;!

+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void (^)(void))animations;

Page 7: Custom Transitions in iOS7 by Leszek Kaczor

Code

Page 8: Custom Transitions in iOS7 by Leszek Kaczor

Custom transitions

UINavigationControllerDelegate

- (id <UIViewControllerAnimatedTransitioning>) navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC

Page 9: Custom Transitions in iOS7 by Leszek Kaczor

Custom transitions

UIViewControllerAnimatedTransitioning

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext

Page 10: Custom Transitions in iOS7 by Leszek Kaczor

Interactive transitions

UINavigationControllerDelegate

- (id<UIViewControllerInteractiveTransitioning>)navigationController: (UINavigationController *)navigationController interactionControllerForAnimationController: (id<UIViewControllerAnimatedTransitioning>)animationController

Page 11: Custom Transitions in iOS7 by Leszek Kaczor

Interactive transitions

• UIViewControllerInteractiveTransitioning

- (void)startInteractiveTransition:(id <UIViewControllerContextTransitioning>)transitionContext

• UIPercentDrivenInteractiveTransition - (void)updateInteractiveTransition:(CGFloat)percentComplete; - (void)cancelInteractiveTransition; - (void)finishInteractiveTransition;

Page 12: Custom Transitions in iOS7 by Leszek Kaczor

Code

Page 13: Custom Transitions in iOS7 by Leszek Kaczor

Podsumowanie

• Proste i intuicyjne API

• Nowe metody do tworzenia animacji

• Interaktywne przejścia pomiędzy widokami