iOS 转场动画

效果图:


转场动画

源码地址(点击跳转)

UIView 转场动画

实现代码:

   UIViewAnimationTransition animationTranstion = transition;
   [UIView animateWithDuration:1 animations:^{
   [UIView setAnimationCurve:curve];
   [UIView setAnimationTransition:animationTranstion forView:self cache:YES];
   }];
   

UIView 基础转场动画 ,UIViewAnimationTransition包含4种:

typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft, // 从左翻页
UIViewAnimationTransitionFlipFromRight, // 从右翻页
UIViewAnimationTransitionCurlUp, // 向上翻书特效
UIViewAnimationTransitionCurlDown, // 向下翻书特效
};

 UIViewAnimationCurve 也有4种

typedef NS_ENUM(NSInteger, UIViewAnimationCurve) {
UIViewAnimationCurveEaseInOut, // slow at beginning and end
UIViewAnimationCurveEaseIn, // slow at beginning
UIViewAnimationCurveEaseOut, // slow at end
UIViewAnimationCurveLinear
};

CALayer 转场动画

实现代码:

    CATransition *transition = [CATransition animation];
    transition.duration = 1;
    transition.type = @"fade"; // 过渡效果
    transition.subtype = @"fromRight"; // 过渡方向
    [view.layer addAnimation:transition forKey:@"transition"];
    

过渡效果 type

fade //交叉淡化过渡(不支持过渡方向)
push //新视图把旧视图推出去
moveIn //新视图移到旧视图上面
reveal //将旧视图移开,显示下面的新视图
cube //立方体翻滚效果
oglFlip //上下左右翻转效果
suckEffect //收缩效果,如一块布被抽走(不支持过渡方向)
rippleEffect //滴水效果(不支持过渡方向)
pageCurl //向上翻页效果
pageUnCurl //向下翻页效果
cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向)
cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)

过渡方向 subtype

fromRight;
fromLeft;
fromTop;
fromBottom;

posted @ 2016-10-09 10:54  Jaesun  阅读(481)  评论(0编辑  收藏  举报