iOS图片立体旋转

图片做动画效果

//动画开始

-(void)startAnimationMsg

{

    num = 0;

    self.timer = [NSTimer timerWithTimeInterval:0.4 target:self selector:@selector(updateAnimationMsg) userInfo:nil repeats:YES];

    [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];

    /*

    CABasicAnimation* rotationAnimation;

    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];

    rotationAnimation.toValue = [NSNumber numberWithFloat: -M_PI * 2.0 ];

    rotationAnimation.duration = 2;

    rotationAnimation.cumulative = YES;

    rotationAnimation.repeatCount = 0;

    [self.OpenImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        [self startAnimation];

    });

     */

}

-(void)updateAnimationMsg

{

    switch (num) {

        case 0:

            self.OpenImageView.image = [UIImage imageNamed:@"img_open-02.png"];

            num ++;

            break;

        case 1:

            self.OpenImageView.image = [UIImage imageNamed:@"img_open-03.png"];

            num++;

            break;

        case 2:

            self.OpenImageView.image = [UIImage imageNamed:@"img_open-01.png"];

            num = 0;

            break;

        default:

            break;

    }

}

//动画结束

-(void)endAnimationMsg

{

     self.OpenImageView.image = [UIImage imageNamed:@"img_open-01.png"];

    [self.timer invalidate];

}

 

原文地址:https://www.cnblogs.com/huzi213/p/7238224.html