旋转并移动UIView



如何使用动画块移动连续旋转的UIView?例如,我有以下用于旋转的代码:

- (void)spinView:(UIView *)view {
    [UIView animateWithDuration:0.2f
                          delay:0.0f
                        options:UIViewAnimationOptionCurveLinear
                     animations:^{
                         view.transform = CGAffineTransformRotate(view.transform, M_PI_2);
                     }
                     completion:^(BOOL finished) {
                         if (finished) {
                             [self spinView:view];
                         }
                     }];
}

如何将其与这样的动画相结合:

[UIView animateWithDuration:4.0f animations:^{
    myView.transform = CGAffineTransformTranslate(myView.transform, 400, 0);
}];

我尝试过CGAffineTransformConcat(),UIViewAnimationOptionBeginFromCurrentState,但没有成功。

你有没有尝试过这样的东西,

[UIView animateWithDuration:2.0f animations:^{
    vw.transform = CGAffineTransformTranslate(vw.transform, 400, 0);
    CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    animation.fromValue = [NSNumber numberWithFloat:0.0f];
    animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
    animation.duration = 5.0f;
    animation.repeatCount = 1;
    [vw.layer addAnimation:animation forKey:@"SpinAnimation"];
}];

大众是你移动的视图。 根据您的意愿设置框架。

最新更新