11月 10 2009

UIVIewをアニメーションさせる

Posted by dos in iphone, iphone Tips

UIViewアニメーションについて

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:0.6f];//アニメーションさせる時間

アニメーションさせたいUIViewの結果を記入します。

[UIView commitAnimations];

以上、このままですね〜。このままでOKです。ただし、


アニメーション終了後に他に何かを行いたい場合は、

CGContextRef contex = UIGraphicsGetCurrentContext();

[UIView beginAnimations:nil context:contex];

[UIView setAnimationCurve:UIViewAnimationCurveLinear];

[UIView setAnimationDuration:0.6f];//アニメーションさせる時間

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(メソッド)];

アニメーション後を記入します。

[UIView commitAnimations];

*setAnimationCurveでアニメーションの調整(「じょじょに加速する」や「一定の速度で」を入れたい場合は記述。(記述が無くてもよいですが)

*setAnimationDidStopSelectorのメソッド名にその後のメソッド名を指定する。

たとえば、移動し終わった後に透明になるなど。

以上です。

動きを入れる事によってアプリを作った感が増す様に思います♪


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>