图像动画。像硬币旋转一样旋转图像

时间:2015-01-30 14:27:34

标签: ios animation rotation

我有一种情况,我必须像硬币一样旋转图像。我这样做。

    CATransition* transition = [CATransition animation];
  transition.startProgress = 0;
   transition.endProgress = 1.0;
  transition.type = @"flip";
  transition.subtype = @"fromRight";
  transition.duration = 1.0;
  transition.repeatCount = 15;

   [rotateimageView.layer addAnimation:transition forKey:@"transition"];

它正在旋转图像,但它没有完全旋转它请检查视频。

https://www.dropbox.com/s/x4t2aqyscgecqfb/animationVideo.mov?dl=0

看起来像是旋转但右箭头从不指向左侧。我想让它左右指向一个完整的硬币动画。

1 个答案:

答案 0 :(得分:0)

查看以下文章,其中我解释了如何旋转横幅。也许你可以在你的应用程序中应用相同的技术。

http://highoncoding.com/Articles/876_Creating_a_Flipping_Tweets_View.aspx

-

(void) updateFlippingView:(NSTimer *) timer
{
    if(index == ([tweets count] -1))
    {
        index = 0;
    }

    UILabel *messageLabel = (UILabel *) [flippingView viewWithTag:MESSAGE_LABEL_TAG];

    [UIView animateWithDuration:1.0 animations:^{

            [UIView animateWithDuration:2.0 animations:^{
                messageLabel.alpha = 0.0;
            } completion:^(BOOL finished) {
                [UIView animateWithDuration:1.0 animations:^{
                    messageLabel.alpha = 1.0;
                    messageLabel.text = [tweets objectAtIndex:index];
                }];

            }];

        flippingView.layer.transform = CATransform3DMakeRotation(rotationIndex *M_PI, 1.0, 0.0, 0.0);

       for(UIView *subView in flippingView.subviews)
            {
                subView.layer.transform = CATransform3DMakeRotation(rotationIndex *M_PI, 1.0, 0.0, 0.0);
            }

        }
            completion:^(BOOL finished) {
           rotationIndex = rotationIndex == 1 ? 2 :1;

        }];

    index++;

}