首页 > 代码库 > 动画 很精辟的
动画 很精辟的
CAlaye的动画
//创建CAlayer动画
CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"bounds.size"];
//设置初始大小
[animation setFromValue:[NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)]];
//设置运行后的方法
[animation setToValue:[NSValue valueWithCGSize:manImageView.bounds.size]];
//设置时常
[animation setDuration:1.2];
//设子代理监听
[animation setDelegate:self];
[manImageView.layer addAnimation:animation forKey:@"image-bounds.size"];
//漂浮的动画
CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
//设置view行动的轨迹
NSArray *values=[NSArray arrayWithObjects:[NSValue valueWithCGPoint:CGPointMake(fx,fy)],
[NSValue valueWithCGPoint:CGPointMake(fx1, fy1)],
[NSValue valueWithCGPoint:CGPointMake(fx2, fy2)],
[NSValue valueWithCGPoint:CGPointMake(fx3, fy3)],
[NSValue valueWithCGPoint:CGPointMake(fx4, fy4)],nil];
//获得点
[animation setValues:values];
//设置时常
[animation setDuration:5.0];
//设置代理监听
[animation setDelegate:self];
[manImageView.layer addAnimation:animation forKey:@"img-position"];
//渐变的动画
CABasicAnimation * animation=[CABasicAnimation animationWithKeyPath:@"opacity"];
//设置透明度最小值
[animation setFromValue:[NSNumber numberWithFloat:1.0]];
//设置透明度最大值
[animation setToValue:[NSNumber numberWithInt:0.0]];
//播放速率
[animation setDuration:3.0];
//播放次数
[animation setRepeatCount:3.0];
//设置监听代理
[animation setDelegate:self];
[animation setAutoreverses:YES];//默认的是NO,即透明完毕后立马恢复,YES是延迟恢复
[manImageView.layer addAnimation:animation forKey:@"img-opacity"];
//立方体的动画
CATransition *animation = [CATransition animation];
//动画名称
animation.type =@"cube";
//翻转方向
animation.subtype = kCATransitionFromLeft;
//时长
[animation setDuration:2];
//代理方法
[animation setDelegate:self];
//上一个动画播放完不移除,默认是YES移除
animation.removedOnCompletion = NO;
[_bView.layer addAnimation:animation forKey:@"docube"];
//水波纹动画
CATransition *animation = [CATransition animation];
animation.type =@"rippleEffect";
[animation setDuration:2];
[animation setRepeatCount:1.0];
[_bView.layer addAnimation:animation forKey:@"s rippleEffect"];
//收缩效果
CATransition *animation = [CATransition animation];
animation.type =@"suckEffect";
[animation setDuration:2];
[animation setRepeatCount:1.0];
[_bView.layer addAnimation:animation forKey:@"s suckEffect"];
//向后翻转动画
CATransition *animation = [CATransition animation];
animation.type =@"oglFlip";
[animation setDuration:2];
[animation setRepeatCount:1.0];
[_bView.layer addAnimation:animation forKey:@"s oglFlip"];
//向上翻页的动画
CATransition *animation = [CATransition animation];
animation.type =@"pageCurl";
[animation setDuration:2];
[animation setRepeatCount:1.0];
[_bView.layer addAnimation:animation forKey:@"s pageCurl"];
跟上边效果相反的动画
CATransition *animation = [CATransition animation];
animation.type =@"pageUnCurl“;
[animation setDuration:2];
[animation setRepeatCount:1.0];
[_bView.layer addAnimation:animation forKey:@"s pageUnCurl"];
这些动画效果跟上边的用法一样
新视图覆盖旧视图
moveIn
旧视图移出露出新视图
reveal
新视图把旧视图推出去
push
立方体向上滚动
alignedCube
相机动画
cameraIris
相机打开效果
cameraIrisHollowOpen
相机关闭效果
cameraIrisHollowClose
* 过渡方向
fromRight;
fromLeft;
fromTop;
fromBottom;