iOS转场动画总结

来源:互联网 发布:linux怎么看内存大小 编辑:程序博客网 时间:2024/06/06 12:30

常见的转场动画

方案一:

//创建转场动画对象

    CATransition *transition = [[CATransitionalloc]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=[selftransitionImage:isNext];

    //添加动画效果

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


画方案二:

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

[UIViewtransitionFromView:view2toView:view1duration:0.5options:UIViewAnimationOptionTransitionFlipFromRightcompletion:^(BOOL finished) {

        //这个api原理  

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

        //        2:[fromvalue removeFromSuperview];

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

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

    }];






0 0
原创粉丝点击