1

フルローテーションをしたいのですが、途中で画像を入れ替えると出来ないようです。完全な回転は下で見ることができます。どうすればこれの半分を作ることができますが、素晴らしいz軸のものを使用しますか?これはanimateWithDurationブロックにあります(iOS4)

// Create perspective transformation
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
myView.layer.transform = transform; //- 3d
myView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0); 
4

1 に答える 1

2

これは、2つのブロックで実行できます。

// Rotate the second 'backside' view to 90 degrees and hide it
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0f / -zDistance;
mySecondView.layer.transform = transform;
mySecondView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);
mySecondView.hidden = YES;

// Animate to 90 degrees
[UIView animateWithDuration:0.5 animations:^{
    CATransform3D transform = CATransform3DIdentity;
    transform.m34 = 1.0f / -zDistance;
    myView.layer.transform = transform;
    myView.layer.transform = CATransform3DMakeRotation(M_PI / 2, -1, 0, 0);

} completion:^{

    // Switch to the backside view
    myView.hidden = YES;
    mySecondView.hidden = NO;

    // Animate the remaining 90 degrees
    [UIView animateWithDuration:0.5 animations:^{
        CATransform3D transform = CATransform3DIdentity;
        transform.m34 = 1.0f / -zDistance;
        mySecondView.layer.transform = transform;
        mySecondView.layer.transform = CATransform3DMakeRotation(M_PI, -1, 0, 0);
    }
}

ビューの背面を非表示にするプロパティを試してみることもできmyView.layer.isDoubleSidedます。ただし、アニメーションの最後でフラグを切り替える必要がありますhidden。そうしないと、最初のビューのボタンをクリックできます。

お役に立てれば!ありがとう。

于 2011-12-29T14:04:03.827 に答える