【问题标题】:iPhone UIView Animation problem with repeatingiPhone UIView 动画重复出现问题
【发布时间】:2011-01-20 02:26:31
【问题描述】:

嗨 我只是在玩一些基本的 UIView 动画。 我将重复计数设置为 100,这样我就可以看到它一遍又一遍地上下波动。 我设置了一个过渡来将我的视图旋转 180 度

我可以看到我的视图在移动时旋转。 然而,经过一些重复.. 视图仍在上下移动,但不再旋转。 我不明白为什么它会停止在同一个循环中旋转?

下面是我的代码:

- (void)viewDidLoad {
[super viewDidLoad];
CGAffineTransform trans = CGAffineTransformMakeRotation(M_PI);
Shape* shapeView = [[Shape alloc] initWithShapeName:@"test" frame:CGRectMake(100, 0, 50, 50)];


[self.view addSubview:shapeView];
[UIView beginAnimations:@"test animation" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationRepeatCount:100];
shapeView.transform = trans;
[UIView setAnimationRepeatAutoreverses:YES];
shapeView.frame = CGRectMake(100,300,50,50);


[UIView commitAnimations];

[shapeView release];

}

谢谢

【问题讨论】:

    标签: iphone animation uiview


    【解决方案1】:

    发生这种情况的原因是因为您设置了动画RepeatAutoreverses 设置了变换。因此,每次形状上升时,仅算作 1 次重复。而旋转方面已经算作 2 次重复。

    换句话说,向下和向后移动的形状是 1 次重复,需要 2 秒。现在,由于旋转未设置为自动反转,因此旋转只需 1 秒即可完成 1 次重复。因此,当形状恢复时,旋转部分已经重复了 2 次。这意味着旋转将在 100 秒后结束,而上下动画将在 200 秒后结束。

    希望我能解释清楚。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 2018-12-06
      相关资源
      最近更新 更多