//关键帧动画之多边形路径
-(void)keyframeAnimation
{
UIImageView *imgView = (UIImageView *)[self.cycleView viewWithTag:10010];
UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(KeyCycleViewDiameter/2.0, KeyCycleViewDiameter/2.0)
radius:(KeyCycleViewDiameter-10)/2.0
startAngle:-M_PI/2.0
endAngle:3*M_PI/2.0
clockwise:YES];
aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理
//创建关键帧动画
CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframeAnimation.path = aPath.CGPath;
keyframeAnimation.fillMode = kCAFillModeForwards;
keyframeAnimation.removedOnCompletion = NO;
keyframeAnimation.duration = 3.0;
[imgView.layer addAnimation:keyframeAnimation forKey:@"keyframe"];
}
江总给我的原来的:
//关键帧动画之多边形路径
-(void)keyframeAnimation{
UIView *animationView = [[UIView alloc] initWithFrame:CGRectMake(10, 5, 30, 30)];
animationView.backgroundColor = [UIColor grayColor];
[self.view addSubview:animationView];
//曲线
UIBezierPath *movePath = [UIBezierPath bezierPath];
[movePath moveToPoint:CGPointMake(150, 15)];//设置当前起点(必须先设置起始点,再次添加曲线后会自动更新结束点,可添加多个形成波浪形)
[movePath addCurveToPoint:CGPointMake(150, 200) controlPoint1:CGPointMake(200, 20) controlPoint2:CGPointMake(100, 180)];
[movePath addCurveToPoint:CGPointMake(150, 400) controlPoint1:CGPointMake(200, 220) controlPoint2:CGPointMake(100, 380)];
//创建关键帧动画
CAKeyframeAnimation *keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyframeAnimation.path = movePath.CGPath;
keyframeAnimation.fillMode = kCAFillModeForwards;
keyframeAnimation.removedOnCompletion = NO;
keyframeAnimation.duration = 3.0;
[animationView.layer addAnimation:keyframeAnimation forKey:@"keyframe"];
}