CGPoint endpoint=[self.view convertPoint:point1 fromView:carBG];
UIBezierPath *path=[UIBezierPath bezierPath];
CGPoint startPoint=[self.view convertPoint:point fromView:self.myTableView];
[path moveToPoint:startPoint];
//贝塞尔曲线中间点
float sx=startPoint.x;
float sy=startPoint.y;
float ex=endpoint.x;
float ey=endpoint.y;
float x=sx+(ex-sx)/3;
float y=sy+(ey-sy)*0.5-400;
CGPoint centerPoint=CGPointMake(x,y);
[path addQuadCurveToPoint:endpoint controlPoint:centerPoint];
CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path = path.CGPath;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
animation.duration=0.8;
animation.delegate=self;
animation.autoreverses= NO;
animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[layer addAnimation:animation forKey:@"buy"];
沒有留言:
張貼留言