【问题标题】:How to animate UIImageView rotation few times in a row如何连续几次为 UIImageView 旋转设置动画
【发布时间】:2011-01-05 13:22:41
【问题描述】:

我正在尝试为 UIImage 视图设置动画,每次顺时针旋转 90 度。 出于某种原因,第一个旋转动画有效,但随后它停止了(即使另一个视图调整大小动画继续有效)。这是为什么? (我到处找,但找不到答案)

{
        [btn setFrame:CGRectMake(previousX, previousY, BUTTON_WIDTH, BUTTON_HEIGHT)];
        [self.view insertSubview:btn atIndex:0];

        [UIView beginAnimations:@"ButtonAnimation" context:nil];

        [UIView setAnimationDuration:2.5];

        [UIView setAnimationCurve:UIViewAnimationCurveLinear];

        CGRect rect = CGRectMake(previousX,previousY+BUTTON_HEIGHT,BUTTON_WIDTH,BUTTON_HEIGHT);

         btn.frame = rect;

        [UIView setAnimationBeginsFromCurrentState:YES]; 

        ++ButtonCounter;
         if (ButtonCounter < [btnArray count])
            {

                [UIView setAnimationDidStopSelector:@selector(didStopReal)];
            }
            else
            {
                ButtonCounter = 0; 
            }


        // The transform matrix
        CGAffineTransform transform = 
        CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));

        imgArrowView.transform = transform;


        [UIView setAnimationDelegate:self];
        [UIView commitAnimations];
}

-(void) didStopReal
{
    [self animteReal:ButtonCounter];
}

【问题讨论】:

    标签: iphone cocoa-touch uiimageview core-animation rotation


    【解决方案1】:

    构建相对于当前变换的变换矩阵:

    CGAffineTransform transform = 
    CGAffineTransformRotate(imgArrowView.transform, DEGREES_TO_RADIANS(90));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 2013-11-13
      • 2015-10-07
      相关资源
      最近更新 更多