服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > 开发教程 > ios开发教程 >

iOS转场动画 WWDC2013 Session218笔记

时间:2016-11-05 09:42来源:未知 作者:最模板 点击:
Presentations and dismissals (模态的显示与消失) UITabBarController (切换) UINavigationController (Pop or Push) UICollectionViewController layout to lyout transitions UIView Animation UIView Animation [UIView animationWithDuration:
  1. Presentations and dismissals (模态的显示与消失)
  2. UITabBarController (切换)
  3. UINavigationController (Pop or Push)
  4. UICollectionViewController layout to lyout transitions

UIView Animation

UIView Animation

[UIView animationWithDuration:....animations:^{
....
}]

Spring AnimationDampingRatio

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

如果dampRatio = 1,则不会有振动,比1越小,振动越剧烈。

New KeyframeAnimation

iOS7 新加的方法可以替代 CAKeyframeAniamtion

+ (void)addKeyframeWithRelativeStartTime:(double)frameStartTime relativeDuration:(double)frameDuration animations:(void (^)(void))animations
+ (void)animateKeyframesWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewKeyframeAnimationOptions)options animations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion NS_AVAILABLE_IOS(7_0);

上述两个方法组合使用:

[UIView animateKeyframesWithDuration:1.3 delay:0 options:(UIViewKeyframeAnimationOptionAllowUserInteraction) animations:^{
	[UIView addKeyframeWithRelative......];    
} completion:nil];

这样就不用每次去通过Layer和CAKeyframeAniamtion来构造关键帧动画了。

Keyframe Animation Options:

UIViewKeyframeAnimationOptionCalculationModeLinear     = 0 << 10, // default
UIViewKeyframeAnimationOptionCalculationModeDiscrete   = 1 << 10,
UIViewKeyframeAnimationOptionCalculationModePaced      = 2 << 10,
UIViewKeyframeAnimationOptionCalculationModeCubic      = 3 << 10,
UIViewKeyframeAnimationOptionCalculationModeCubicPaced = 4 << 10

iOS转场动画 WWDC2013 Session218笔记

曲线横轴表示时间,纵轴表示改变量的变化情况,比如我们修改的alpha、width之类的。

在CAKeyframeAnimation中的rotation可以直接使用view的transform来代替。

SnapShot

UIDynamics

Transitions:

1. delegate:

  1. <UINavigationControllerDelegate>
  2. <UITabBarControllerDelegate>
  3. <UIViewControllerTransitionDelegate>

2. Animation Controllers:

负责添加视图以及执行动画,conforms to <UIViewControllerAnimatedTransitioning>

3. Interaction Controllers:

手势驱动动画控制器实现的动画,

conforms to <UIViewControllerInteractiveTransitioning>

4. Transition Context:

conforms to <UIViewControllerContextTransitioning>

5. Transition Coordinator

在转场动画发生时执行其他的动画

conforms to <UIViewControllerTransitionCoordinator>

Protocols:

UIViewControllerContextTransitioning

// 转场动画发生的容器。
- (UIView *)containerView;

// get controllers: use two keys:
// keys:
NSString *const UITransitionContextFromViewControllerKey;
NSString *const UITransitionContextToViewControllerKey;
- (nullable __kindof UIViewController *)viewControllerForKey:(NSString *)key;

// 获取一个controller的初始frame
- (CGRect)initialFrameForViewController:(UIViewController *)vc

// 获取最终frame
- (CGRect)finalFrameForViewController:(UIViewController *)vc

UIViewControllerAnimatedTransitioning负责切换中的具体内容

// 切换时UIView的设置与动画在此实现
- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext

// 返回动画所需时间。
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext

UIViewControllerTransitioningDelegate

// 
- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source;
//
- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed;
//
- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator;
//
- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator;
//
- (nullable UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source NS_AVAILABLE_IOS(8_0);

手势

UIViewControllerContextTransitioning

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

Class: UIPercentDrivenInteractiveTransition

// 更新百分比,比如说根据手势滑动的距离
- (void)updateInteractiveTransition:(CGFloat)percentComplete;
// notify to the system that the transition has been canceled
- (void)cancelInteractiveTransition;
// notify to the system that the transition has finished
- (void)finishInteractiveTransition;

UIViewControllerInteractiveTransitioning

- (void)startInteractiveTransition:(id <UIViewControllerContextTr

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容