UIView *_redView = [[UIView alloc] init];
_redView.frame = CGRectMake(100,100,200,200);
_redView.backGroundColor = [UIColor redColor];
position移动
CAKeyframeAnimation*anim = [CAKeyframeAnimation animation];
//设置动画属性
anim.keyPath=@"position";
UIBezierPath*path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0,0,200,200)];
anim.path= path.CGPath;
anim.duration=2.0;
//取消反弹
anim.removedOnCompletion=NO;
anim.fillMode=kCAFillModeForwards;
anim.repeatCount = MAXFLOAT;
//kCAMediaTimingFunctionEaseInEaseOut:动画一开始比较慢,中间会加速,临近结束会变慢
anim.timingFunction= [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[_redView.layer addAnimation:animforKey:nil];
rotation抖动效果
#define angle2radian(x) ((x) /180.0* M_PI)
CAKeyframeAnimation*anim = [CAKeyframeAnimation animation];
anim.keyPath=@"transform.rotation";
anim.values=@[@(angle2radian(-5)),@(angle2radian(5)),@(angle2radian(-5))];
anim.repeatCount=MAXFLOAT;
anim.duration=0.5;
[_redView.layer addAnimation:anim forKey:nil];
CATransition
CATransition*anim = [CATransition animation];
anim.type=@"pageCurl";
fade//交叉淡化过渡(不支持过渡方向)
push//新视图把旧视图推出去
moveIn//新视图移到旧视图上面
reveal//将旧视图移开,显示下面的新视图
cube//立方体翻滚效果
oglFlip//上下左右翻转效果
suckEffect//收缩效果,如一块布被抽走(不支持过渡方向)
rippleEffect//滴水效果(不支持过渡方向)
pageCurl//向上翻页效果
pageUnCurl//向下翻页效果
cameraIrisHollowOpen//相机镜头打开效果(不支持过渡方向)
cameraIrisHollowClose//相机镜头关上效果(不支持过渡方向)
anim.subtype=kCATransitionFromLeft;
//anim.startProgress = 0.5;
anim.duration=2;
[_redView.layer addAnimation:anim forKey:nil];