1

この回答によると、 CGAffineTransform を永続的にする方法があります:

iphone - CGAffineTransform を永続的にする

しかし、それは説明されていません...答えは、アニメーションによって生成されたコピーについて述べていますが、それを取得して元のオブジェクトに割り当てる方法が明確ではないため、これがコードです。永続的にする方法は?

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];

[UIView setAnimationRepeatAutoreverses:NO];
[UIView setAnimationRepeatCount:1];

[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

float angleRadians = 180 * ((float)M_PI / 180.0f);
CGAffineTransform t = CGAffineTransformMakeRotation(angleRadians);

self.myView.transform = t;
[self.myView setCenter:CGPointMake(160, 220)];

[UIView commitAnimations];

ありがとう

4

2 に答える 2

1

レベルを下げてCoreAnimationに移動し、次のプロパティを使用して変換アニメーションを適用してみてください。

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.fromValue = [NSValue valueWithCATransform3D: t];
animation.toValue = [NSValue valueWithCATransform3D: t];
animation.duration = 0.0;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
[yourView.layer addAnimation:animation forKey:@"transform"];

次に、他のコアアニメーションを実行でき、変換を保持する必要があります。QuartzCoreフレームワークをインポートすることを忘れないでください。

于 2011-08-31T21:26:28.463 に答える
0

iOS 4.0 以降では、Apple はブロック ベースのアニメーションの使用を推奨しています。

参考:iPhone OS 4.0のブロックベースのアニメーション方式とは?

    [UIView animateWithDuration:0.3 
                      delay:0 
                    options:UIViewAnimationOptionCurveEaseOut 
                 animations:^{ self.myView.transform = CGAffineTransformMakeRotation(M_PI) } 
                 completion:NULL];

これで問題が正確に解決されるかどうかはわかりませんが、正しい方向への一歩です。

于 2011-09-01T15:38:02.557 に答える