您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页iOS 贝塞尔曲线 一

iOS 贝塞尔曲线 一

来源:二三娱乐
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

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务