标签:style color os 使用 io for ar art div
1.1->创建动画对象CABasicAnimation *anim = [CABasicAnimation animation];
1.2->设置动画对象
keyPath决定了执行怎样的动画, 调整哪个属性来执行动画
anim.keyPath = @"transform.rotation";
anim.keyPath = @“bounds";
anim.keyPath = @“transform";
anim.keyPath = @“transform.translation.x”;
//起始状态,如果不设置则默认从图层所在位置开始动画
anim.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
//结束状态
anim.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
byValue : 增加多少值 toValue:最终变成值的多少
//动画时长
anim.duration = 2.0;
//重复次数
anim.repeatCount = MAXFLOAT;
1.3 ->让图层保持动画执行完毕后的状态
// 动画执行完毕后不要删除动画
anim.removedOnCompletion = NO;
// 保持最新的状态
anim.fillMode = kCAFillModeForwards;
1.4 ->添加动画到图层
[self.layer addAnimation:anim forKey:nil];(后面的这个key值是可以指定某一个动画的)
2、CAKeyframeAnimation(关键帧动画)
2.1->创建动画对象CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
2.2->设置动画对象
keyPath决定了执行怎样的动画, 调整哪个属性来执行动画
anim.keyPath = @"transform.rotation";
anim.keyPath = @“bounds";
anim.keyPath = @“transform";
anim.keyPath = @“transform.translation.x”;
//动画时长
anim.duration = 2.0;
//重复次数
anim.repeatCount = MAXFLOAT;
// 设置动画的执行节奏
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//设置动画的执行路径(也可以设置关键帧数组)
CGMutablePathRef path = CGPathCreateMutable();
CGPathAddEllipseInRect(path, NULL, CGRectMake(100, 100, 200, 200));
anim.path = path;
//注意:C语言中如果使用了create方法创建的,都要释放,不然会有内存泄漏
CGPathRelease(path);
//设置关键帧数组(也可以设置动画的执行路径)
anim.keyPath = @"position";
NSValue *v1 = [NSValue valueWithCGPoint:CGPointZero];
NSValue *v2 = [NSValue valueWithCGPoint:CGPointMake(100, 0)];
NSValue *v3 = [NSValue valueWithCGPoint:CGPointMake(100, 200)];
NSValue *v4 = [NSValue valueWithCGPoint:CGPointMake(0, 200)];
anim.values = @[v1, v2, v3, v4];
2.3 ->让图层保持动画执行完毕后的状态
// 动画执行完毕后不要删除动画
anim.removedOnCompletion = NO;
// 保持最新的状态
anim.fillMode = kCAFillModeForwards;
2.4 ->添加动画到图层
[self.layer addAnimation:anim forKey:nil];(后面的这个key值是可以指定某一个动画的)
2.5 ->移除动画(如果要移除一个动画,那么这个动画一定要设置Key值)
[self.iconView.layer removeAnimationForKey:@“shake"];
3、CATransition(转场动画)
4、CAAnimationGroup(动画组)3.1->创建动画对象CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
3.2->设置动画对象
anim.type = @“pageUnCurl";
anim.subtype = kCATransitionFromLeft;
anim.startProgress = 0.0;
anim.endProgress = 0.5;
3.3 ->添加动画到图层
[self.layer addAnimation:anim forKey:nil];
// 4.1.创建旋转动画对象CABasicAnimation *rotate = [CABasicAnimation animation];
rotate.keyPath = @"transform.rotation";
rotate.toValue = @(M_PI);
// 4.2.创建缩放动画对象
CABasicAnimation *scale = [CABasicAnimation animation];
scale.keyPath = @"transform.scale";
scale.toValue = @(0.0);
// 4.3.平移动画
CABasicAnimation *move = [CABasicAnimation animation];
move.keyPath = @"transform.translation";
move.toValue = [NSValue valueWithCGPoint:CGPointMake(100, 100)];
// 4.4.将所有的动画添加到动画组中
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[rotate, scale, move];
group.duration = 2.0;
group.removedOnCompletion = NO;
group.fillMode = kCAFillModeForwards;
// 4.5.把动画组添加到图层中
[self.myvie.layer addAnimation:group forKey:nil];
5、其它动画
1 -> //好像只适用在iPad上,也是类似于转场动画(?)[UIView transitionWithView:self.view duration:1.0 options:UIViewAnimationOptionTransitionCurlUp animations:nil completion:nil];2->[UIView beginAnimations:nil context:nil];self.myview.center = CGPointMake(200, 300);
[UIView commitAnimations];
3 -> [UIView animateWithDuration:1.0 animations:^{
self.myview.center = CGPointMake(200, 300);
} completion:^(BOOL finished) {
}];
标签:style color os 使用 io for ar art div
原文地址:http://www.cnblogs.com/bluceZ/p/3938385.html