前言
我寫了乙個簡單的動畫集tableviewanimationkit,只需要一行**就可以讓tableview實現動畫
目前有大概10個動畫,後續會優化增加。
正文
一、效果展示:
二、使用方法
tableviewanimationkit呼叫各個動畫的方法都為類方法,只需一行**就可以呼叫。
eg:1
[tableviewanimationkit shakeanimationwithtableview:tableview];
tableviewanimationkit提供的動畫類方法
1
2
3
4
5
6
7
8
9
10
+ (void)moveanimationwithtableview:(uitableview *)tableview;
+ (void)alphaanimationwithtableview:(uitableview *)tableview;
+ (void)fallanimationwithtableview:(uitableview *)tableview;
+ (void)shakeanimationwithtableview:(uitableview *)tableview;
+ (void)overturnanimationwithtableview:(uitableview *)tableview;
+ (void)totopanimationwithtableview:(uitableview *)tableview;
+ (void)springlistanimationwithtableview:(uitableview *)tableview;
+ (void)shrinktotopanimationwithtableview:(uitableview *)tableview;
+ (void)laydonwanimationwithtableview:(uitableview *)tableview;
+ (void)roteanimationwithtableview:(uitableview *)tableview;
三、原始碼講解
先舉其中乙個動畫效果為例子:
動畫效果為cell左右各自插入。
實現**很簡單如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+ (void)shakeanimationwithtableview:(uitableview *)tableview
else
[uiview animatewithduration:0.4 delay:i*0.03 usingspringwithdamping:0.75 initialspringvelocity:1/0.75 options:0 animations:^ completion:^(bool finished) ];
}
}
主要思路為:
獲得tableview的visiblecells陣列,進行遍歷,對每個執行動畫,不同cell的執行時間、方向有所差異,一起構成整個動畫。
四、其他一些動畫效果
後語
iOS tableView分割槽 索引
1.建立乙個viewcontroller,new file cocoa touch objective c class class viewcontroller,subclass of uiviewcontroller 2.開啟xib,在view中新增tableview,並將tableview的兩個...
iOS tableView效能優化
什麼時候呼叫 每當有乙個cell進入視野範圍內就會呼叫 uitableviewcell tableview uitableview tableview cellforrowatindexpath nsindexpath indexpath 3.覆蓋資料 cell.textlabel.text nss...
iOS tableView 上下偏移
說一下問題吧,xcode10 向下相容到ios8,ios10以下版本會出現tableview向上或者向下偏移很是煩人。於是山寨了乙個解決方案 該方法適用於向上偏移 void tableview uitableview tableview willdisplaycell uitableviewcell...