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

4

我有这样的情况,需要像硬币一样旋转图像。我正在按照以下步骤进行。

    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

看起来像是旋转,但是右指向箭头从未指向左侧。我希望它能够像完整的硬币动画一样左右指向。


可能是Flip transition in iPhone的重复问题。 - Ian MacDonald
1个回答

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++;

}

仅提供链接的答案不受欢迎,因为如果链接失效,答案就毫无用处。您应该在答案中包含解决方案的关键部分。 - Jesse Rusak

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接