iOS核心動畫keypath

2021-07-22 13:45:51 字數 3153 閱讀 4118

transform.rotation:旋轉動畫。

transform.rotation.x:按x軸旋轉動畫。

transform.rotation.y:按y軸旋轉動畫。

transform.rotation.z:按z軸旋轉動畫。

transform.scale:按比例放大縮小動畫。

transform.scale.x:在x軸按比例放大縮小動畫。

transform.scale.y:在y軸按比例放大縮小動畫。

transform.scale.z:在z軸按比例放大縮小動畫。

position:移動位置動畫。

opacity:透明度動畫

strokeend :顏色從無到有

strokestart :顏色從有到無

// do any additional setup after loading the view, typically from a nib.

// (360°- 30°) ->(180°+30°) 逆時針的圓弧 cd圓弧

uibezierpath *path1 = [uibezierpath bezierpathwitharccenter:cgpointmake(self.view.center.x,self.view.center.y)

radius:100

startangle:2 * m_pi - degrees_to_radians(30)

endangle:m_pi + degrees_to_radians(30)

clockwise:no];

// (3/2π- 60°) ->(-1/2π -60°) 逆時針的圓 dd′圓

uibezierpath *path2 = [uibezierpath bezierpathwitharccenter:cgpointmake(self.view.center.x,self.view.center.y)

radius:100

startangle:m_pi *3/2 - (m_pi_2 - degrees_to_radians(30))

endangle:-m_pi_2 - (m_pi_2 -degrees_to_radians(30))

clockwise:no];

cashapelayer *layer = [cashapelayer layer];

layer.path = path1.cgpath;

layer.strokecolor = [uicolor redcolor].cgcolor;

layer.fillcolor = [uicolor clearcolor].cgcolor;

layer.linewidth = 5;

cashapelayer *layer1 = [cashapelayer layer];

layer1.path = path2.cgpath;

layer1.strokecolor = [uicolor yellowcolor].cgcolor;

layer1.fillcolor = [uicolor clearcolor].cgcolor;

layer1.linewidth = 5;

//方案1

cakeyframeanimation *startanimation = [cakeyframeanimation animationwithkeypath:@"strokestart"];

startanimation.values = @[@0,@1];

startanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseout];

startanimation.duration = 2 ;

startanimation.repeatcount = 100;

startanimation.delegate = self;

startanimation.removedoncompletion = 1;

cakeyframeanimation *endanimation = [cakeyframeanimation animationwithkeypath:@"strokeend"];

endanimation.values = @[@0,@1];

endanimation.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseout];

endanimation.duration = 2;

endanimation.repeatcount = 100;

endanimation.delegate = self;

endanimation.removedoncompletion = 1;

caanimationgroup *animationgroup = [caanimationgroup animation];

animationgroup.animations = [nsarray arraywithobjects:startanimation,nil];

animationgroup.timingfunction = [camediatimingfunction functionwithname:kcamediatimingfunctioneaseout];

animationgroup.duration = 3;

animationgroup.repeatcount = 100;

animationgroup.delegate = self;

animationgroup.removedoncompletion = 1;

[animationgroup setvalue:@"animationstep3" forkey:@"animationname"];

[layer addanimation:startanimation forkey:nil];

[layer1 addanimation:endanimation forkey:nil];

[self.view.layer addsublayer:layer];

[self.view.layer addsublayer:layer1];

IOS核心動畫

void basicanimation calayer layer animation.duration 2 animation.delegate self animation.removedoncompletion no animation.fillmode kcafillmodeforwards...

IOS開發核心動畫篇 核心動畫簡介

ios開發ui篇 核心動畫簡介 一 簡單介紹 core animation,中文翻譯為核心動畫,它是一組非常強大的動畫處理api,使用它能做出非常炫麗的動畫效果,而且往往是事半功倍。也就是說,使用少量的 就可以實現非常強大的功能。core animation是跨平台的,可以用在mac os x和io...

iOS核心動畫 基礎動畫

核心動畫 在ios中核心動畫分為幾類 基礎動畫 cabasicanimation 關鍵幀動畫 cakeyframeanimation 動畫組 caanimationgroup 轉場動畫 catransition caanimation 核心動畫的基礎類,不能直接使用,負責動畫執行時間 速度的控制,本...