Download - Custom Transitions in iOS7 by Leszek Kaczor
Custom transitionsUntitled Kingdom Ltd
Leszek Kaczor
Przebieg prezentacji
• Nowe metody do tworzenia animacji • spring animations • keyframe animations
• Przejścia pomiędzy widokami • animacyjne (custom transitions) • interaktywne (interactive transitions)
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
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
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;
Code
Custom transitions
UINavigationControllerDelegate
- (id <UIViewControllerAnimatedTransitioning>) navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
Custom transitions
UIViewControllerAnimatedTransitioning
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
Interactive transitions
UINavigationControllerDelegate
- (id<UIViewControllerInteractiveTransitioning>)navigationController: (UINavigationController *)navigationController interactionControllerForAnimationController: (id<UIViewControllerAnimatedTransitioning>)animationController
Interactive transitions
• UIViewControllerInteractiveTransitioning
- (void)startInteractiveTransition:(id <UIViewControllerContextTransitioning>)transitionContext
• UIPercentDrivenInteractiveTransition - (void)updateInteractiveTransition:(CGFloat)percentComplete; - (void)cancelInteractiveTransition; - (void)finishInteractiveTransition;
Code
Podsumowanie
• Proste i intuicyjne API
• Nowe metody do tworzenia animacji
• Interaktywne przejścia pomiędzy widokami