2011年9月20日火曜日

UIViewの機能でアニメーションを行う。

UIViewの機能でアニメーションを行う。

ページの中で位置を移動したり、透過度を変更して
フェードインをするなどの動作を行う動作を行う。

step1
部分の初期状態の設定

中央の位置を決める
_iv.center = CGPointMake(x,y)

大きさの設定
_iv.rect = CGRectMake(x,y,width,height);

回転角度の設定
_iv.transform = CGAffineTransformMakeRotation(30 * 2*m_PI/360);

透明度
_iv.alpha = 0.5;

step2アニメーションの設定をする。

開始は
[UIView beginAnimations:nil context:nil];

アニメーションの秒数の設定は
[UIView setAnimationRepeatCount:3]
※0だと無限に繰り返す

開始までの時間
[UIView setAnimationDelay:3];

イージング設定
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
ゆっくり→はやく→ゆっくり:UIViewAnimationCurveEaseInOut
ゆっくり→はやく:UIViewAnimationCurveEaseIn
はやく→ゆっくり:UIViewAnimationCurveEaseOut
一定の速度:UIViewAnimationCurveEaseLiner
の4種類が基本


アニメーションの組み込みの流れ、
//初期設定
_iv.center = CGPointMake(20,20);

//宣言
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];

//結果
_iv.center =  CGPointMake(50,100);

//出力
[UIView commitAnimations];

0 件のコメント:

コメントを投稿