Tk-iPhone
unread,Oct 1, 2010, 1:55:23 AM10/1/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to iPhone Developer Japan
みなさんこんにちは。お世話になります。
CALayerの扱いについて質問させていただきます。(プロジェクトはView-basedで作成)
たとえばW:150 , H150のサイズのUIView(以降aView)とボタン(以降aButton)を追加して
このaView内に任意の画像やテキストを配置したとします。
それから、このaViewのレイヤーをCALayer *alayer = aVIew.layer;とし、
aButtonを押した時のアクションを以下のような3D回転させたとします。
(alayerの左辺を軸に本をめくるような回転をします。)
alayer.anchorPoint = CGPointMake(0.0f, 0.5f);
alayer.position = CGPointMake(***, ***); //aViewを設置した場所により変動
//レイヤーアニメーションの生成
CABasicAnimation* anime=[CABasicAnimation
animationWithKeyPath:@"transform"];
anime.removedOnCompletion=NO;
anime.fillMode=kCAFillModeForwards;
anime.duration=1.0f;
anime.repeatCount=1;
anime.autoreverses=NO;
CATransform3D transform;
transform = CATransform3DIdentity;
anime.fromValue=[NSValue valueWithCATransform3D:transform];
transform = CATransform3DMakeRotation(M_PI,0,1,0);
transform.m34 = 1.0f / 420.0f;
anime.toValue=[NSValue valueWithCATransform3D:transform];
//レイヤーへアニメーション追加
[alayer addAnimation:anime forKey:@"rotation"];
これを実行するとalayerが左辺を軸に180度回転し、alayerの裏側が見える状態になります。
(最初にaView内に追加した画像やテキストが左右反転している状態です。)
このalayerの裏側に縦横同サイズの違うUIView(以降bView)を表示することは可能でしょうか?
このbViewは回転終了後にbView内に追加した画像やテキストが左右反転していない正常に見える
状態にしたいです。
自分で試したのはbViewの上にaViewを重ねてbViewのレイヤー(以降blayer)とalayerを
同時に上記と同じ回転をさせてレイヤーの重ね順などを変更してみましたが、ダメでした。
もしわかる方がいらっしゃいましたらご教授ください。
以上よろしくお願いします。