![Upload 2016-01-27 15_42_00.gif failed. Please try again.]YouXianMing 大神的github地址
https://github.com/YouXianMing/Tween-o-Matic-CN
这是个自定义贝塞尔曲线值的mac工具,可以方便的加入到代码中。如以下:
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(0, 50, 100, 100);
layer.backgroundColor = [UIColor redColor].CGColor;
UIButton *btna = [[UIButton alloc]init];
btna.layer.frame =CGRectMake(0, 50, 100, 100);
// 终点位置
CGPoint endPosition = CGPointMake(layer.position.x, layer.position.y + 200);
// 动画
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];
animation.fromValue = [NSValue valueWithCGPoint:layer.position];
animation.toValue = [NSValue valueWithCGPoint:endPosition];
animation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.00 :0.00 :1.00 :1.00];
layer.position = endPosition;
animation.duration = 1.f;
// 添加动画
[layer addAnimation:animation forKey:nil];
// 添加layer
[self.view.layer addSublayer:layer];
工具截图:
2016-01-27 15_42_00.gif 2016-01-27 15_48_45.gif
右侧的数值,直接复制粘贴到代码中,就可以看到效果了。
我的github下载代码 https://github.com/PowerYang/Bezier-Animation
网友评论