CAPropertyAnimation additive
来源:互联网 发布:js div显示隐藏 编辑:程序博客网 时间:2024/04/30 13:52
再做一些shaking动画时,通常会指定对称的左右几个点,加入都CAKeyframeAnimation.values中。
但是这就需要计算present layer的点,不太方便。
看了下CAPropertyAnimation有个属性是additive,这个属性根据当前的渲染层的值加上value生成新的渲染的值,也就是动画时present layer的值。
Determines if the value specified by the animation is added to the current render tree value to produce the new render tree value.
下边的代码的动画效果是一样的,对比下values会有个明确的认识:
- (void)change
{
CAKeyframeAnimation* animation = [CAKeyframeAnimationanimationWithKeyPath:@"position.x"];
animation.values =@[@0,@100,@(-100),@100,@0];
animation.keyTimes =@[@0,@(1/6.),@(3/6.),@(5/6.),@1];
animation.duration =2.f;
animation.additive =YES; //YES把更改的值追加到当前的present层中 keypath+=value,NO是把更改的值设置成当前present层的值keypath = value
[self.ly.layeraddAnimation:animation forKey:@"shaking"];
CAKeyframeAnimation* animation1 = [CAKeyframeAnimationanimationWithKeyPath:@"position.x"];
animation1.values =@[@(self.ly1.center.x),@(self.ly1.center.x + 100),@(self.ly1.center.x -100),@(self.ly1.center.x +100),@(self.ly1.center.x)];
animation1.keyTimes =@[@0,@(1/6.),@(3/6.),@(5/6.),@1];
animation1.duration =2.f;
animation1.additive =NO; //YES把更改的值追加到当前的model层中 keypath+=value,NO是把更改的值设置成当前present层的值keypath = value
[self.ly1.layeraddAnimation:animation1 forKey:@"shaking"];
[buttonanimateWithType:arc4random()%3];
[selfperformSelector:@selector(change)withObject:nilafterDelay:3.f];
}
- CAPropertyAnimation additive
- CAPropertyAnimation 用法
- CAPropertyAnimation 用法
- 基础动画CAPropertyAnimation
- additive tree
- Additive equations
- Additive equations
- Additive equations
- Additive equations
- Additive number
- Additive Number
- Additive Number
- Additive Number
- Additive equations
- iOS动画笔记之-----CAPropertyAnimation
- Core Animation - 属性动画CAPropertyAnimation
- (CAPropertyAnimation、CABasicAnimation、CAKeyframeAnimation、CAAnimationGroup介绍)
- (CAPropertyAnimation、CABasicAnimation、CAKeyframeAnimation、CAAnimationGroup介绍)
- Cocos2dx 3.3 遇到的问题
- Javascript 初学者应知的 24 条最佳实践
- OpenCV: OpenCV中IplImage图像格式
- 剑指offer-8 旋转数组的最小数字
- 调试打断点无效解决方法
- CAPropertyAnimation additive
- 一个简单的auth perl程序
- Eclipse中如何查看andriod apk真机运行的日志
- Scala 表达式编程实践
- cvCreateMemStorage函数
- 如何成为羽毛球高手?你距离一个真正的羽毛球高手还有多远?
- iOS开发的22个奇谲巧技
- android.os.Build的一些使用方法
- CADisplayLink以及和NSTimer的区别