0

アプリで現在使用されているプッシュ アニメーションを置き換えるように設計された CATransform3D アニメーションがあります。現在、X 軸がレイヤー/ビューの中心にあるかのように回転します。ただし、X 軸を画面の端に配置して、画面からはみ出すようにします。私の現在のコードは次のとおりです: -

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
    rotationAndPerspectiveTransform.m34 = 1.0 / 500;
    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 1.57, 0, 1, 0);
    self.view.layer.transform = rotationAndPerspectiveTransform;
    [UIView commitAnimations];

私は Core Graphics などに不慣れなので、私が間違っているポインタ、ヒントは大歓迎です!

4

1 に答える 1

1

anchorPointレイヤーの を変更する必要があります。beginAnimations:context:メソッドの前に次のコードを使用します。

CGRect frame = self.view.layer.frame;
self.view.layer.anchorPoint = CGPointMake(1.f, 0.5f);
self.view.layer.frame = frame;

これanchorPointにより、レイヤーの位置を変更せずにレイヤーの が変更されます。回転アニメーションは、アンカー ポイントから通過する軸を中心に行われます。

于 2012-12-14T22:32:54.317 に答える