美文网首页
360度 顺时针旋转3种方法

360度 顺时针旋转3种方法

作者: seventhboy | 来源:发表于2016-11-18 19:33 被阅读89次

    NSInteger angle = 0;
    -(void)startAnimation1
    {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.05];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationWillStartSelector:@selector(startAnimationStart)];
    [UIView setAnimationDidStopSelector:@selector(startAnimation1)];
    angle += 5;
    AnminationImageD.transform = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
    [UIView commitAnimations];

    }
    -(void)startAnimation2
    {
    CGAffineTransform endAngle = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));

    [UIView animateWithDuration:0.01 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
        AnminationImageD.transform = endAngle;
    } completion:^(BOOL finished) {
        angle += 10;
        [self startAnimation2];
    }];
    

    }
    -(void)startAnimation3{
    CABasicAnimation* rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
    rotationAnimation.duration = 5.0;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 1000;
    [AnminationImageD.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    }

    相关文章

      网友评论

          本文标题:360度 顺时针旋转3种方法

          本文链接:https://www.haomeiwen.com/subject/yrdspttx.html