一、建立uiview動畫(塊)--(指過渡效果的動畫)
基本方式:使用uiview類的uiviewanimation擴充套件。
1、**示例:
//開始準備動畫
[uiview beginanimations:nil context:nil];
//定義動畫加速或減速方式
[uiview setanimationcurve: uiviewanimationcurvelinear];
//動畫時長
[uiview setanimationduration: 2.7];
//設定過渡效果
[uiview setanimationtransition: transition forview: self.view cache: yes];
//動畫中所做的改變,改變的obj應與forview中的對應
[self.view exchangesubviewatindex: [self.view.subviews indexofobject(index1)]
withsubviewatindex: [self.view.subviews indeofobject(index2)]
];//動畫結束
[uiview commitanimation];
上面提到的transition引數取值範圍:uiview類自身提供四種過渡效果。
uiviewanimationtranstionnone 無過渡
uiviewanimationtranstionflipfromleft 從左到右翻轉
uiviewanimationtranstionflipfromright從右到左翻轉
uiviewanimationtranstioncurlup 從下向上卷
uiviewanimationtranstioncurldown 從上向下卷
2、還有另一種形式:
//返回當前檢視堆疊頂部的圖形上下文
cgcontextref context = uigraphicsgetcurrentcontext();
[uiview beginanimations: nil context: context];
//以下內容如上
……二、block方式:使用uiview類的uiviewanimationwithblocks擴充套件
1、**示例:
[uiview animatewithduration: 2.7 //動畫時長
delay: 2.7 //延遲
options: (uiviewanimationoptions) options
animations: ^(void) completion: ^(bool finished)
];常見的是其巢狀使用。
三、core方式: 使用catransition類
1、須知:
catransition只針對圖層,不針對檢視。圖層是core animation與每個uiview產生聯絡的工作層面。使用core animation時,應該將catransition應用到檢視的預設圖層([myview layer])而不是檢視本身。
使用catransiton類實現動畫,只需要建立乙個core animation物件,設定它的引數,然後把這個帶引數的過渡新增到圖層即可。
使用前要引入quartzcore.framework庫,並在相應處新增**#import 。
2、**示例:
//定義動畫
catransition *transition = [catransition animation];
//間隔時間
transition.duration = 0.5f;
//動畫開始與結束的快慢
transition.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout];
//動畫效果
transition.type = kcatransitionfade;
//動畫方向
transition.subtype = kcatransitionfromright;
= self;
[self.layer addanimation: transition forkey:nil];
layer所在圖層的變化;
3、catransition的過渡效果型別:
公開的:
kcatransitionfade 淡化
kcatransitionmovein 覆蓋
kcatransitionpush 推擠
kcatransitionreveal 揭開
非公開的:
@」cube」 立方體
@」suckeffect」 吸收
@」oglflip」 翻轉
@」rippleeffect」 波紋
@」pagecurl」 卷頁
@」camerairishollowopen」 鏡頭開
@」camerairishollowclose」 鏡頭關
四、uiimageview自身動畫屬性
可以方便地實現幻燈片效果
1、**示例:
//齒輪轉動
uiimageview *tmpview = [[uiimageview alloc] initwithframe:cgrectmake(133, 118, 50, 50)];
[self.view addsubview:tmpview];
tmpview.animationduration = 0.3;
tmpview.animationimages = tmparray;
tmpview.animationrepeatcount = 0;
[tmpview startanimating];
[tmpview release];
tmpview引數為陣列,存放uiimage物件。
五、其它相關總結
因為在設計動畫的過程中,為了體現出檢視動態的效果,有些屬性和方法我們還需深入了解一下。
1、uiview的frame、bounds、center屬性的區別。
frame:該view在父view座標系中的位置和大小。(參照點是父親的座標系統)
bounds:該view在本地座標系中的位置和大小。(參照點是本地座標系)
center:該view的中心點在父view座標系中的位置和大小。(參照點是父親的座標系)
2、檢視縮放、旋轉、移動。
//將檢視的大小轉變為正常大小的200%
cgaffinetransform newtransform = cgaffinetransformmakescal(2.0, 2.0);
//新增到相應檢視中
[btn settransform: newtransform];
//檢視的旋轉
cgaffinetransform newtransform = cgaffinetransformmakerotate(transform, m_pi);
或cgaffinetransform newtransform = cgaffinetransformmakerotation(-m_pi);
//檢視的移動
cgaffinetransform newtransform = cgaffinetransformmaketranslation(width, 0.0);
iphone5上市總結版
iphone5基本資料 1.上市時間及地區 北京時間9月5日凌晨訊息,蘋果周二發出邀請函,邀請 參加定於美國東部時間9月12日 北京時間9月13日 召開的發布會。業界廣泛預計該公司將發布iphone 5。從邀請函來看,蘋果巧妙地將 12 這個數字投射的陰影描繪成數字 5 暗示蘋果將把 iphone命...
學習影視動畫的心得
學習影視動畫的心得 7天力方魔鬼訓練營 首先十分感謝學校領導 老師給我這麼好的機會學習一些我以前沒有接觸過的新知識,如果 沒有你們的幫助,作為教育新人的我是絕對沒有機會到省裡參加乙個這麼好的培訓,學到這 麼多有用的新知識的。這次在力方教育培訓儘管時間不是很長,只有短短的七天,但是我卻在這七天的時間裡...
動畫實踐教學總結
總結行之初早在學期之初動畫設計專業和產品造型專業的認識實習問題就早已被提到了議事日程。而在這期間2010年的4月份,董俊華老師提出了乙個原始的動畫指令碼思路,就是根據現有的條件,製作一部動畫片。緊接著,大家根據現有的物質和技術條件,由原來的二維動畫轉到了定格動畫的思路上來,加上動畫設計班幾個同學自發...