最普通動畫:
//開始動畫
[uiview beginanimations:nil context:nil];
//設定動畫持續時間
[uiview setanimationduration:2];
//動畫的內容
frame.origin.x += 150;
[img setframe:frame];
//動畫結束
[uiview commitanimations];
連續動畫:乙個接乙個地顯示一系列的影象
nsarray *myimages = [nsarray arraywithobjects:
[uiimage imagenamed:@"myimage1.png"],
[uiimage imagenamed:@"myimage2.png"],
[uiimage imagenamed:@"myimage3.png"],
[uiimage imagenamed:@"myimage4.gif"], nil];
uiimageview *myanimatedview = [uiimageview alloc];
[myanimatedview initwithframe:[self bounds]];
myanimatedview.animationimages = myimages; //animationimages屬性返回乙個存放動畫的陣列
myanimatedview.animationduration = 0.25; //瀏覽整個一次所用的時間
myanimatedview.animationrepeatcount = 0; // 0 = loops forever 動畫重複次數
[myanimatedview startanimating];
[self addsubview:myanimatedview];
[myanimatedview release];
catransition public api動畫:
catransition *animation = [ catransition animation ];
//動畫時間
animation.duration = 0.5f ;
//先慢後快
animation. timingfunction = uiviewanimationcurveeaseinout;
animation. fillmode = kcafillmodeforwards;
//animation.removedoncompletion = no;
//各種動畫效果
kcatransitionfade;
kcatransitionmovein;
kcatransitionpush;z
kcatransitionreveal;
kcatransitionfromright;
kcatransitionfromleft;
kcatransitionfromtop;
kcatransitionfrombottom;
//各種組合
animation. type = kcatransitionpush;
animation. subtype = kcatransitionfromright;
[self .view .layer addanimation :animation forkey :@"animation" ];
catransition private api動畫:
animation.type可以設定為以下效果
動畫效果彙總:
suckeffect(三角)
rippleeffect(水波抖動)
pagecurl(上翻頁)
pageuncurl(下翻頁)
oglflip(上下翻轉)
camerairis/camerairishollowopen/camerairishollowclose (鏡頭快門,這一組動畫是有效果,只是很難看,不建議使用
而以下為則黑名單:
speweffect: 新版面在螢幕下方中間位置被釋放出來覆蓋舊版面.
- genieeffect: 舊版面在螢幕左下方或右下方被吸走, 顯示出下面的新版面 ( 阿拉丁燈神?).
- ungenieeffect: 新版面在螢幕左下方或右下方被釋放出來覆蓋舊版面.
- twist: 版面以水平方向像龍捲風式轉出來.
- tubey: 版面垂直附有彈性的轉出來.
- swirl: 舊版面 360度旋轉並淡出 , 顯示出新版面 .
- charminultra: 舊版面淡出並顯示新版面 .
- zoomyin: 新版面由小放大走到前面, 舊版面放大由前面消失.
- zoomyout: 新版面螢幕外面縮放出現, 舊版面縮小消失.
uiview animations 動畫:
[ uiview beginanimations: @"animationid" context: nil ];
[ uiview setanimationduration: 0.5f ];
[ uiview setanimationcurve: uiviewanimationcurveeaseinout];
[ uiview setanimationrepeatautoreverses: no ];
//以下四種效果
[ uiview setanimationtransition: uiviewanimationtransitionflipfromleft forview: self . view cache: yes ]; //oglflip, fromleft
[ uiview setanimationtransition: uiviewanimationtransitionflipfromright forview: self . view cache: yes ]; //oglflip, fromright
[ uiview setanimationtransition: uiviewanimationtransitioncurlup forview: self . view cache: yes ];
[ uiview setanimationtransition: uiviewanimationtransitioncurldown forview: self . view cache: yes ];
[ self . view exchangesubviewatindex: 1 withsubviewatindex: 0 ];
[ uiview commitanimations];
ios4.0新方法:
方法: +(void)animatewithduration:(nstimeinterval)duration animations:(void (^)(void))animations;
+ (void)animatewithduration:(nstimeinterval)duration animations:(void (^)(void))animations completion:(void (^)(bool finished))completion; //多乙個動畫結束後可以執行的操作.
//下邊是巢狀使用,先變大再消失的動畫效果.
[ uiview animatewithduration: 1.25 animations:^
completion :^(bool finished) completion :^(bool finished)];
cocoa china-各種動畫效果demo:http://www.cocoachina.com/bbs/read.php?tid-11820.html
UIView實現動畫效果
uiview類的很多屬性都設計為動畫,動畫的屬性是指當屬性從乙個值變成另外乙個值時可以支援動畫,同時通知uikit需要執行什麼樣型別的動畫,uiview物件支援動畫的屬性有如下幾個 frame屬性 可以使用該屬性改變尺寸和位置 bounds 改變尺寸 center 改變檢視的位置 alpha 改變檢...
ios各種動畫效果
最普通動畫 開始動畫 uiview beginanimations nil context nil 設定動畫持續時間 uiview setanimationduration 2 動畫的內容 frame.origin.x 150 img setframe frame 動畫結束 uiview commi...
iOS 動畫 UIView動畫
viewcontroller.m ui 23 動畫 import viewcontroller.h inte ce viewcontroller property strong,nonatomic iboutlet uiview opeview1 property strong,nonatomic ...