使用前
需引入quartzcore.framework, 並在相關檔案中加入 #import "quartzcore/quartzcore.h"
定義 shakefeedbackoverlay為uiimageview
設定 self.shakefeedbackoverlay.alpha = 0.0;
self.shakefeedbackoverlay.layer.cornerradius = 10.0; //設定圓角半徑
1、影象左右抖動
cabasicanimation* shake = [cabasicanimation animationwithkeypath:@"transform.rotation.z"];
shake.fromvalue = [nsnumber numberwithfloat:-m_pi/32];
shake.tovalue = [nsnumber numberwithfloat:+m_pi/32];
shake.duration = 0.1;
shake.autoreverses = yes; //是否重複
shake.repeatcount = 4;
[self.shakefeedbackoverlay.layer addanimation:shake forkey:@"shakeanimation"];
self.shakefeedbackoverlay.alpha = 1.0;
[uiview animatewithduration:2.0 delay:0.0 options:uiviewanimationoptioncurveeasein | uiviewanimationoptionallowuserinteraction animations:^ completion:nil];
2、影象順時針旋轉
cabasicanimation* shake = [cabasicanimation animationwithkeypath:@"transform.rotation.z"];
shake.fromvalue = [nsnumber numberwithfloat:0];
shake.tovalue = [nsnumber numberwithfloat:2*m_pi];
shake.duration = 0.8; shake.autoreverses = no;
shake.repeatcount = 1;
[self.shakefeedbackoverlay.layer addanimation:shake forkey:@"shakeanimation"];
self.shakefeedbackoverlay.alpha = 1.0;
[uiview animatewithduration:10.0 delay:0.0 options:uiviewanimationoptioncurveeasein | uiviewanimationoptionallowuserinteraction animations:^ completion:nil];
3、影象關鍵幀動畫
cakeyframeanimation *animation = [cakeyframeanimation animation];
cgmutablepathref apath =cgpathcreatemutable();
cgpathmovetopoint(apath, nil, 20, 20);
cgpathaddcurvetopoint(apath, nil, 160, 30, 220, 220, 240, 420);
animation.path = apath;
animation.autoreverses = yes;
animation.duration = 2;
animation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseout];
animation.rotationmode = @"auto";
[ballview.layer addanimation:animationforkey:@"position"];
4、組合動畫 caanimationgroup
cabasicanimation *flip = [cabasicanimation animationwithkeypath:@"transform.rotation.y"];
flip.tovalue = [nsnumbernumberwithdouble:-m_pi];
cabasicanimation *scale= [cabasicanimation animationwithkeypath:@"transform.scale"];
scale.tovalue = [nsnumbernumberwithdouble:12];
scale.duration = 1.5;
scale.autoreverses = yes;
caanimationgroup *group = [caanimationgroup animation];
group.animations = [nsarray arraywithobjects:flip, scale,nil];
group.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout];
group.duration = 3;
group.fillmode = kcafillmodeforwards;
group.removedoncompletion =no;
[ballview.layer addanimation:groupforkey:@"position"];
5、指定時間內旋轉
//啟動定時器旋轉光圈
- (void)startrotate
//關閉定時器
- (void)stoptimer}
//旋轉動畫
- (void)rotategraduation
else
;}呼叫方法
self.timecount = 25; //動畫執行25次
[self startrotate];
移動到右下角
//向右下角縮小移動
- (ibaction)buttonclick:(id)sender
//向右邊旋轉
- (ibaction)rightrotatebtnclick:(id)sender
//旋轉360度
- (ibaction)rota360btnclick:(id)sender
常見的動畫效果(二)
需引入quartzcore.framework 並在相關檔案中加入 import quartzcore quartzcore.h 定義 shakefeedbackoverlay為uiimageview 設定self.shakefeedbackoverlay.alpha 0.0 self.shakef...
Flex的動畫效果與變換 二
本文出自 在上篇文章 flex的動畫效果與變換 一 中講到了使用flex系統裡面自帶的一些動來效果的使用,但很多開發者都並不滿足flex裡提供的簡單的漸變大小,透明,移動,遮罩等的效果,如果是flash的開發者的話,更不用說了,在flash,多數人都是隨意的製作一些動畫效果等,而且形態多變。但是不是...
Flex動畫效果與變換 二
很多開發者都並不滿足flex裡提供的簡單的漸 變大小,透明,移動,遮罩等的效果,如果是flash的開發者的話,更不用說了,在flash,多數人都是隨意的製作一些動畫效果等,而且形態多變。但是 不是flex裡就不能實現呢?肯定不是,在flex裡也可以自定義動畫效果,只不過就是沒有flash裡面那麼簡單...