CoreAnimationでの3D回転とPerspective表示

CoreAnimationを使ってUIViewを回転させるとき、3D回転や表示をさせるためには、
下の例のように、Rotateしたあとに、別のRotateとはConcatする必要がある。
また、Perspective表示にする場合には.m34の設定をおこなう。

// コンパスアイコンの回転(3Dパースペクティブ)
CATransform3D commpassTransform = CATransform3DIdentity;
commpassTransform = CATransform3DRotate(commpassTransform, -M_PI*magHeading/180.0, 0, 0, 1);	
commpassTransform = CATransform3DConcat(commpassTransform, CATransform3DMakeRotation(M_PI*50.0/180.0, 1, 0, 0));

CATransform3D perspective = CATransform3DIdentity;
perspective.m34 = 1.0 / -80;	

commpassTransform = CATransform3DConcat(commpassTransform, perspective);
compassView.layer.transform = commpassTransform;
最終更新:2010年09月11日 15:15
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。