iOS转场动画总结

常见的转场动画

方案一:

//创建转场动画对象

    CATransition *transition = [[CATransition alloc]init];

    

    /* The name of the transition. Current legal transition types include

     * `fade', `moveIn', `push' and `reveal'. Defaults to `fade'. */

    /**

     *   1.#define定义的常量

     kCATransitionFade   交叉淡化过渡  默认

     kCATransitionMoveIn 新视图移到旧视图上面,覆盖原图

     kCATransitionPush   新视图把旧视图推出去  ,推出

     kCATransitionReveal 将旧视图移开,显示下面的新视图 ,从底部显示

     

     2.用字符串表示

     pageCurl            向上翻一页

     pageUnCurl          向下翻一页

     rippleEffect        滴水效果

     suckEffect          收缩效果,如一块布被抽走

     cube                立方体效果

     oglFlip             上下翻转效果

     注意:

     还有很多私有API效果,使用的时候要小心,可能会导致app审核不被通过(悲剧啊,为啥有却不让用啊!好东西不应该被束之高阁!)

     fade     //交叉淡化过渡(不支持过渡方向)

     push     //新视图把旧视图推出去

     moveIn   //新视图移到旧视图上面

     reveal   //将旧视图移开,显示下面的新视图

     cube     //立方体翻滚效果

     oglFlip  //上下左右翻转效果

     suckEffect   //收缩效果,如一块布被抽走(不支持过渡方向)

     rippleEffect //滴水效果(不支持过渡方向)

     pageCurl     //向上翻页效果

     pageUnCurl   //向下翻页效果

     cameraIrisHollowOpen  //相机镜头打开效果(不支持过渡方向)

     cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)

     

     */

    //设置动画类型,注意对于苹果官方没有公开的动画类型智能使用字符串,并没有对应的常量意义

    // transaction.type=@"pageCurl";//控制图片的滑动类型

    if (isNext == YES) {

        transition.type     =   @"pageCurl";

        transition.subtype  =   kCATransitionFromRight;

    } else {

        transition.type     =   @"cube";

        transition.subtype  =   kCATransitionFromLeft;

    }

    //设置动画时长,默认为0

    transition.duration=1.0;

    

    /* The amount of progress through to the transition at which to begin

     * and end execution. Legal values are numbers in the range [0,1].

     * `endProgress' must be greater than or equal to `startProgress'.

     * Default values are 0 and 1 respectively. */

    //动画开始的进度

    //  transaction.startProgress=0.1;

    //动画结束的进度,,,结束的进度必须大于开始的进度

    //  transaction.endProgress=0.5;

    //动画的速度

    // transaction.speed=100.0;

    

    //设置转场后的新视图添加转场动画

    self.imageView.image=[self transitionImage:isNext];

    //添加动画效果

    [self.imageView.layer addAnimation:transition forKey:@"Animation"];


画方案二:

可以直接调用下面这个函数

[UIView transitionFromView:view2 toView:view1 duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight completion:^(BOOL finished) {

        //这个api 原理  

        //        1:[fromvalue.superview addSubview:tovalue];

        //        2:[fromvalue removeFromSuperview];

//        NSLog(@"fromvalue-->%@",fromvalue.superview);

//        NSLog(@"tovalue-->%@",tovalue.superview);

    }];






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值