iOS转场动画总结

5834次常见的转场动画方案1://创建转场动画对象CATransition *transition = [[CATransitionalloc]init];/* The name of the transition. Current l。

5834次

常见的转场动画

方案1:

//创建转场动画对象

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 向上翻1页

pageUnCurl 向下翻1页

rippleEffect 滴水效果

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

cube 立方体效果

oglFlip 上下翻转效果

注意:

还有很多私有API效果,使用的时候要谨慎,可能会致使app审核不被通过(悲剧啊,为啥有却不让用啊!好东西不应当被置之不理!)

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

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

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

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

cube//立方体翻滚效果

oglFlip//上下左右翻转效果

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

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"];

画方案2:

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

[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);

}];

综上所述,以上就是关于iOS转场动画总结的全部内容了,字数约11447字,希望能够解决你的困惑。屹东网往后会继续推荐iOS转场动画总结相关内容。