#import "viewcontroller.h"
@inte***ce viewcontroller ()
@property (nonatomic,strong)uiview *myview;
//轉場動畫 切換的檢視
@property (nonatomic,strong)uiview *firstview;
@property (nonatomic,strong)uiview *secondview;
//轉場動畫 標記是否正在進行動畫
@property (nonatomic,assign)bool isanimating;
@end
@implementation viewcontroller
- (void)viewdidload
-(void)touchesbegan:(nsset*)touches withevent:(uievent *)event];
*/#pragma mark uiview動畫 ---轉場動畫
/*if (!_isanimating) else
} completion:^(bool finished) ];}*/
#pragma mark layer
/*layer是圖層,uiview其實是分兩層的,上面一層是透明的框負責處理使用者響應,下面一層是圖層,負責圖形的繪製
*/#pragma mark cgaffinetransform2d 仿射變換屬性
//設定動畫效果
[uiview beginanimations:@"仿射變換" context:nil];
//設定動畫速度
[uiview setanimationduration:1];
//旋轉
/* = cgaffinetransformmakerotation(m_pi_2);
//旋轉無限次
// cgaffinetransform transform = self.myview.transform;
// self.myview.transform = cgaffinetransformrotate(transform, m_pi_2 * 10);
*///縮放
/*// self.myview.transform = cgaffinetransformmakescale(2, 1);
//多次縮放
cgaffinetransform transform = self.myview.transform;
self.myview.transform = cgaffinetransformscale(transform, 1, 1.1);
*///提交動畫
[uiview commitanimations];
#pragma mark caanimation
進行layer層的旋轉
/*cabasicanimation *base = [cabasicanimation animationwithkeypath:@"transform.rotation"];//後面的字串是固定的名字,讀取系統的檔案資訊
//持續時間
base.duration = 50;
//起始的角度
base.fromvalue = @(0);
//終止的角度
base.tovalue = @(m_pi_2 * 10000);
//將這個動畫新增到layer上
[self.myview.layer addanimation:base forkey:@"base"];
*/ 用於顏色改變的
/*cakeyframeanimation *key1 = [cakeyframeanimation animationwithkeypath:@"backgroundcolor"];
//使用
key1.duration =5;
id c1 = (id)[uicolor greencolor].cgcolor;
id c2 = (id)[uicolor blackcolor].cgcolor;
id c3 = (id)[uicolor yellowcolor].cgcolor;
id c4 = (id)[uicolor redcolor].cgcolor;
key1.values = @[c1,c2,c3,c4];
//新增動畫
[self.myview.layer addanimation:key1 forkey:@"color"];
self.myview.backgroundcolor = [uicolor blackcolor];
*///3.位置的改變
/*cakeyframeanimation *key2 = [cakeyframeanimation animationwithkeypath:@"position"];
key2.duration = 5;
nsvalue *v1 = [nsvalue valuewithcgpoint:cgpointmake(0, 0)];
nsvalue *v2 = [nsvalue valuewithcgpoint:cgpointmake([uiscreen mainscreen].bounds.size.width - 100, 0)];
nsvalue *v3 = [nsvalue valuewithcgpoint:cgpointmake([uiscreen mainscreen].bounds.size.width - 100, [uiscreen mainscreen].bounds.size.height - 100)];
nsvalue *v4 = [nsvalue valuewithcgpoint:cgpointmake(0 , [uiscreen mainscreen].bounds.size.height - 100)];
key2.values = @[v1,v2,v3,v4,v1];
// [self.myview.layer addanimation:key2 forkey:@"position"];
*///動畫組
/*同時將多個動畫分組,按組新增,
*//*
caanimationgroup *group = [caanimationgroup animation];
group.duration = 5;
group.animations = @[key2,key1];
[self.myview.layer addanimation:group forkey:@"group"];
*///catransition(切換特效)
catransition *transition = [catransition animation];
transition.duration = 1;//設定時間
transition.type = @"pageuncurl";//設定切換的型別
transition.subtype = kcatransitionfromleft;//設定切換的子型別
[self.myview.layer addanimation:transition forkey:@"transition"];
}@end
iOS開發UI篇 核心動畫 基礎動畫
一 簡單介紹 capropertyanimation的子類 屬性解析 list fromvalue keypath相應屬性的初始值 tovalue keypath相應屬性的結束值 list 隨著動畫的進行,在長度為duration的持續時間內,keypath相應屬性的值從fromvalue漸漸地變為...
iOS開發UI篇 核心動畫 基礎動畫
一 簡單介紹 capropertyanimation的子類 屬性解析 fromvalue keypath相應屬性的初始值 tovalue keypath相應屬性的結束值 隨著動畫的進行,在長度為duration的持續時間內,keypath相應屬性的值從fromvalue漸漸地變為tovalue 如果...
iOS之UI 轉場動畫
1.什麼是轉場動畫?就是從乙個場景轉換到另乙個場景,像導航控制器的push效果,就是乙個轉場.2.如何建立轉場動畫 建立轉場動畫 catransition anim catransition animation 設定轉場型別 anim.type cube anim.duration 1 設定轉場的方...