私は非常に厄介な問題に直面しています。 ここにコンテキストがあります:私はメインビューのサブビューである「長方形」ビューを持っています。 私がしようとしていることは簡単です。ボタンをクリックすると、x軸を平行移動して消えるようにするために、「四角形」ビューを表示します。以前の「長方形」ビューの代わりに新しいサブビューを追加して翻訳します。 ボタンをもう一度押すと、CGAffineTransformMakeTranslationが新しい「長方形」ビューのフレームを変更しないように、アニメーションが画面から開始されるという点を除いては問題ありません。 は、ここでは、コードです:iPhone/iPad - Core Animation - CGAffineTransformMakeTranslationはフレームを変更しません
UIView *rectangleView = [detailView viewWithTag:4]; //the actual frame is (20.0, 30.0, 884.0, 600.0)
[UIView animateWithDuration:0.5 animations:^{
[rectangleView setTransform:CGAffineTransformMakeTranslation(-1000, 0)];
} completion:^(BOOL finished) {
[rectangleView removeFromSuperview];
UIView *otherView = [[UIView alloc] initWithFrame:CGRectMake(1020.0, 30.0, 884.0, 600.0)];
[otherView setBackgroundColor:[UIColor purpleColor]];
[otherView setTag:4];
[detailView addSubview:otherView];
[UIView animateWithDuration:0.5 animations:^{
[otherView setTransform:CGAffineTransformMakeTranslation(-1000, 0)];
} completion:^(BOOL finished) {
[otherView release];
}];
}];
これは機能しています。おかげで多くのウラジミール。私は別の(おそらく愚かな)質問があります。ビューに変換があるかどうかをテストする方法はありますか?何かのように(![rectangleView transform])NSLog(@ "変換がないので、連結する必要はありません") – Dabrut
@Dave、ビューの変換をCGAffineTransformIsIdentity関数で確認できます – Vladimir
ありがとう:) – Dabrut