x軸旋**
//第一種
cabasicanimation *theanimation;
theanimation=[cabasicanimation animationwithkeypath:@"transform.rotation.x"];
theanimation.duration=8;
theanimation.removedoncompletion = yes;
theanimation.fromvalue = [nsnumber numberwithfloat:0];
theanimation.tovalue = [nsnumber numberwithfloat:3.1415926];
[yourview.layer addanimation:theanimation forkey:@"animatetransform"];
//第二種
[uiview animatewithduration:1 delay:0 options:uiviewanimationoptioncurveeasein animations:^ completion:^(bool finished) ];
y軸旋**
cabasicanimation *theanimation;
theanimation=[cabasicanimation animationwithkeypath:@"transform.rotation.y"];
theanimation.duration=8;
theanimation.removedoncompletion = yes;
theanimation.fromvalue = [nsnumber numberwithfloat:0];
theanimation.tovalue = [nsnumber numberwithfloat:3.1415926];
[yourview.layer addanimation:theanimation forkey:@"animatetransform"];
z軸旋**
cabasicanimation *theanimation;
theanimation=[cabasicanimation animationwithkeypath:@"transform.rotation.z"];
theanimation.duration=8;
theanimation.removedoncompletion = yes;
theanimation.fromvalue = [nsnumber numberwithfloat:0];
theanimation.tovalue = [nsnumber numberwithfloat:3.1415926];
[yourview.layer addanimation:theanimation forkey:@"animatetransform"];
以上縮放是以view的中心點為中心縮放的,如果需要自定義縮放點,可以設定卯點:
//中心點
[yourview.layer setanchorpoint:cgpointmake(0.5, 0.5)];
//左上角
[yourview.layer setanchorpoint:cgpointmake(0, 0)];
//右下角
[yourview.layer setanchorpoint:cgpointmake(1, 1)];
可設引數
theanimation.repeatcount = 0;
theanimation.autoreverses = no;
旋轉的另一種實現:(以下**繞z軸旋轉180度)
[self.topviewcontroller.view.layer setanchorpoint:cgpointmake(0.5, 0.5)];
[self.topviewcontroller.view.layer settransform:catransform3dmakerotation(0, 0, 0, 1)];
[uiview animatewithduration:8 delay:0.0f options:uiviewanimationoptionallowuserinteraction | uiviewanimationcurveeasein animations:^ completion:^(bool finished) ];
ios layer 動畫 x y z軸 旋轉
x軸旋 第一種 cabasicanimation theanimation theanimation cabasicanimation animationwithkeypath transform.rotation.x theanimation.duration 8 theanimation.rem...
IOS layer常用動畫
專案中總是需要用到一些動畫效果 1.過度動畫 就是view的漸變效果,偷懶經常使用漸變效果。pragma mark 過度動畫 void guoduanimation uiview view 2.移動動畫 pragma mark 橫向 縱向移動 cabasicanimation movex float...
iOS layer層的轉場動畫
layer層的轉場動畫 直接上 void viewdidload void btnfun 屬性 說明type 動畫過渡型別 subtype 動畫過度方向 有4種分別是 fromleft,fromright,fromtop and frombottom。不是所有的type都有subtype start...