ios 旋轉縮放等動畫

2021-07-02 18:29:14 字數 1452 閱讀 6689

效果:檢視從大--小縮放顯示/小--大 (只是比例問題)

方法1.直接show出view的時候:

把下面的這段**加到viewcontroller或者view出現的時候就ok

self.view.transform = cgaffinetransformmakescale(1.0f, 1.0f);//將要顯示的view按照正常比例顯示出來

[uiview beginanimations:nil context:uigraphicsgetcurrentcontext()];

[uiview setanimationcurve:uiviewanimationcurveeaseinout]; //inout 表示進入和出去時都啟動動畫

[uiview setanimationduration:0.5f];//動畫時間

self.view.transform=cgaffinetransformmakescale(0.01f, 0.01f);//先讓要顯示的view最小直至消失

[uiview commitanimations]; //啟動動畫

//相反如果想要從小到大的顯示效果,則將比例調換

//uigraphicsgetcurrentcontext 裡面東西很豐富。

——————————————————————————————————————————

方法2.push乙個viewcontroller時:

把下面的**加到push的方法裡面就ok

catransition *mytranstiton = [catransition animation];

mytranstiton.duration = 0.5;

mytranstiton.type = kcatransitionfade; 

= kcatransitionfromtop; 

[self.view.superview.layer addanimation:mytranstiton forkey:nil ]; 

mainviewcontroller * _mainviewcontroller=[[mainviewcontroller alloc] init];

[self presentmodalviewcontroller:_mainviewcontroller animated:no];      

transform我們一般稱為形變屬性,其本質是通過矩陣變化改變控制項的大小、位置、角度等,這裡我們通過乙個例子來看一下具體的操作,在下面的例子中我們也會看到uiimageview控制項的常用操作。

//旋轉

- (ibaction)rotationbuttonpressed:(id

)sender  

//縮放

- (ibaction)scalebuttonpressed:(id

)sender  

- (ibaction)movebuttonpressed:(id

)sender   

android動畫,旋轉,漸變,縮放

旋轉動畫 rotateanimation animation new rotateanimation 0,360,animation.relative to self,0.5f,animation.relative to self,0.5f 引數說明 float fromdegrees 旋轉的開始角...

iOS開發 旋轉 縮放 平移

一 建立乙個uiview import viewcontroller.h inte ce viewcontroller property nonatomic,strong uiview myview end implementation viewcontroller void viewdidload...

android 屬性動畫(縮放,漸變,移動,旋轉)

首先設定乙個,引入布局 第二步 初始化initdata getsupportactionbar hide 隱藏標題欄 displaymetrics displaymetrics getresources getdisplaymetrics 這個好像是可以獲取螢幕高度 int height displ...