02 基本動畫的介紹

2021-09-13 21:57:14 字數 1274 閱讀 1184

1、建立乙個最基本的動畫,然後往y軸做乙個移動,

當執行動畫的時候,真正移動的不是layer本身,而是presentation tree,當動畫移動的時候,會把原始塗層隱藏,動畫完成後,就會把presentation圖層移除,原始塗層就會顯示,所以動畫會恢復成原來的狀態

-(void)touchesbegan:(nsset*)touches withevent:(uievent *)event
2、動畫結束之後,停留在移動後的位置

// 建立動畫

cabasicanimation *baseanimation = [cabasicanimation animation];

// 設定動畫的移動方向

baseanimation.keypath = @"position.y";

// 設定動畫的移動距離

baseanimation.tovalue = @400;

// 設定動畫的移動時間

baseanimation.duration = 1;

//是否在動畫結束後將其移除

baseanimation.removedoncompletion = no;

// 設定layer最後的位置狀態

/*** kcafillmodeforwards :動畫結束後,layer會一直保持動畫的最後狀態

* kcafillmodebackwards :動畫開始前,會馬上顯示第一幀的動畫,然後等動畫執行完後,layer會一直保持動畫的最後狀態

* kcafillmodeboth: kcafillmodeforwards & kcafillmodebackwards

* kcafillmoderemoved: 預設,動畫結束後,layer會回到原來的狀態

*/baseanimation.fillmode = kcafillmodeforwards;

// 把動畫新增到layer上面

[_redview.layer addanimation:baseanimation forkey:nil];

3、隱式動畫的控制-修改背景顏色新增動畫效果

[catransaction begin];

// 設定動畫時間

[catransaction setanimationduration:1];

_layer.backgroundcolor = [uicolor yellowcolor].cgcolor;

[catransaction commit];

CABasicAnimation基本動畫 各種屬性

cabasicanimation 使用方法animationwithkeypath 對cabasicanimation 進行例項化註冊,並指定layer的屬性作為關鍵路徑註冊 cabasicanimation transformanimation cabasicanimation animation...

jQuery基本動畫

jquery效果 一 基本效果 顯示與隱藏 通過控制寬高實現 1.show 顯示 無參版本 不具有動畫效果 show speed,callback 有參版本 具有動畫效果 speed 設定動畫執行的時長,單位為毫秒 三個預定義值 slow normal fast callback 當動畫執行完畢後執...

02 numpy 02 陣列的基本運算

在numpy中實現四則運算,既可以使用符號,也可以使用函式 比較運算返回的是bool型別的值,即true 或者 false 比較運算用來篩選出特定的值或者對這些值進行一些操作 import numpy as nparr np.array 1,3,4 5,6,7 3,3,9 arr1 np.array...