ios 核心動畫CoreAnimation

2021-08-04 19:18:16 字數 2064 閱讀 6419

核心動畫其實就是core animation可以用在mac os x 和ios的平台

core animation 的動畫執行過程都是在後台進行操作的,不會堵塞主線程。

core animation是直接作用在calayer上,不是作用在uiview上。

核心動畫可以修改動畫執行的時間

核心動畫結束後會回到原來的位置

1、基本動畫(cabasicanimation)

2、關鍵幀動畫(cakeyframeanimation)

3、組動畫(caanimationgroup)

4、轉場動畫(catransition)

-(void)touchesbegan:(nsset*)touches withevent:(uievent *)event

關鍵幀動畫也是屬性動畫的一種

-(void)touchesbegan:(nsset*)touches withevent:(uievent *)event

組動畫中包含基本動畫和關鍵幀動畫

//建立組動畫

caanimationgroup * group=[[caanimationgroup alloc]init];

//建立基本動畫

cabasicanimation * animation=[[cabasicanimation alloc]init];

animation.keypath=@"transform.rotation";

//讓方塊自己自旋轉

animation.byvalue=@(2*m_pi);

//建立關鍵幀動畫

cakeyframeanimation * animation1 =[[cakeyframeanimation alloc]init];

//怎麼做動畫

animation1.keypath=@"position";

//建立路徑

uibezierpath * path=[uibezierpath bezierpathwitharccenter:cgpointmake(150, 150) radius:100 startangle:0 endangle:2*m_pi clockwise:yes];

//設定關鍵幀動畫的路徑

animation1.path=path.cgpath;

//設定組動畫中的動畫

group.animations=@[animation,animation1];

//設定動畫的執行時間

group.duration=2;

//重複次數

group.repeatcount=int_max;

//新增動畫

[self.layer addanimation:group forkey:nil];

轉場動畫,其中self.imagenumber只是為了更好的去設定而去定義的

- (ibaction)imagechange:(uiswipegesturerecognizer *)sender 

self.imageview.image=[uiimage imagenamed:[nsstring stringwithformat:@"%ld",self.imagenumber]];

//設定方向,從右往左

animation.subtype=kcatransitionfromright;

}else

//設定方向

animation.subtype=kcatransitionfromleft;

self.imageview.image=[uiimage imagenamed:[nsstring stringwithformat:@"%ld",self.imagenumber]];

}//新增動畫效果

[self.imageview.layer addanimation:animation forkey:nil];

}

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 核心動畫的基礎類,不能直接使用,負責動畫執行時間 速度的控制,本...