【问题标题】:iOS 7 UIView animateWithDuration:animations:completion: resets its actions at any kind of transformationiOS 7 UIView animateWithDuration:animations:completion: 在任何类型的转换中重置其操作
【发布时间】:2014-06-11 20:57:54
【问题描述】:

我最近遇到了我的应用程序的问题。

我经常用

[UIView animateWithDuration:(NSTimeInterval) animations:^{...} completion:^(BOOL finished) {...}];

制作我的动画,直到现在它都运行良好。这是我的问题代码

UIImageView *someimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"someimage"]];
[someimage setFrame:CGRectMake(0, 0, 200, 200)];
[self.view addSubView:someimage];
[UIView animateWithDuration:0.5 animations:^{
    [someimage setFrame:CGRectMake(400, 400, 200, 200)];
} completion:^(BOOL finished) {
    NSLog(@"Just finish moving some image lets rotate it!");
    [UIView animateWithDuration:0.5 animations:^{
        someimage.transform = CGAffineTransformMakeRotation(M_PI);
    } completion:^(BOOL finished) {
        NSLog(@"What just happened?");
    }];
}];

我得到了一张图片,我使用动画将它从一个角落移动到另一个位置。然后,当动画完成时,我旋转它,但是当我进行旋转时,UIImageView 再次出现在角落。

谁能解释一下为什么会发生这种情况以及如何处理?

谢谢!

【问题讨论】:

    标签: ios animation uiview core-animation catransition


    【解决方案1】:

    UIView 类参考说:

    警告如果变换属性不是恒等变换,则 此属性的值未定义,因此应忽略。

    同时更改视图(或图层)的框架及其变换无法按预期工作。而是更改视图的中心属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多