CATransition转场动画

-(void)startAnimation:(NSInteger)idx{

/**转场动画代码*/

//创建转场动画对象

CATransition*anim = [CATransition  animation];

switch(idx) {

case1:

anim.type=@"cube";

anim.subtype=kCATransitionFromLeft;

break;

case2:

anim.type=@"suckEffect";

anim.subtype=kCATransitionFromRight;

break;

case3:

anim.type=@"oglFlip";

anim.subtype=kCATransitionFromTop;

break;

case4:

anim.type=@"rippleEffect";

anim.subtype=kCATransitionFromBottom;

break;

case5:

anim.type=@"pageCurl";

anim.subtype=kCATransitionFromBottom;

break;

case6:

anim.type=@"pageUnCurl";

anim.subtype=kCATransitionFromBottom;

break;

case7:

anim.type=@"rotate";

anim.subtype=@"90cw";

break;

case8:

anim.type=@"cameraIrisHollowOpen";

anim.subtype=kCATransitionFromBottom;

break;

case9:

anim.type=@"cameraIrisHollowClose";

anim.subtype=kCATransitionFromBottom;

break;

case10:

anim.type=@"rotate";

anim.subtype=kCATransitionFromBottom;

break;

default:

anim.type=@"pageUnCurl";

anim.subtype=kCATransitionFromTop;

break;

}

//设置转场类型

//    anim.type = @“pageCurl";

//type:

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

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

//subtype:

/* An optional subtype for the transition. E.g. used to specify the

* transition direction for motion-based transitions, in which case

* the legal values are `fromLeft', `fromRight', `fromTop' and

* `fromBottom'. */

//设置动画的方向

//    anim.subtype = kCATransitionFromLeft;

anim.duration=3;

[self.transView.layer  addAnimation:anim   forKey:nil];

}

1.动画的type值

1)@"cube"立方体效果

2)@"suckEffect"收缩效果,如一块布被抽走

3)@"oglFlip"上下翻转效果

4)@"rippleEffect"滴水效果

5)@"pageCurl"向上翻一页

6)@"pageUnCurl"向下翻一页

7)@"rotate"旋转效果

8)@"cameraIrisHollowOpen"

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

9)@"cameraIrisHollowClose"

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

2.当type为@"rotate"(旋转)的时候,它也有几个对应的subtype,分别为:

1)90cw逆时针旋转90°

2)90ccw顺时针旋转90°

3)180cw逆时针旋转180°

4)180ccw顺时针旋转180°

你可能感兴趣的:(CATransition转场动画)