图片绕某一圆心画圆

//关键帧动画之多边形路径

-(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"];
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值