一行代码让你的TableView动起来-iOS动画
来源:互联网 发布:playclub捏脸详细数据 编辑:程序博客网 时间:2024/05/22 10:39
点击上方“iOS开发”,选择“置顶公众号”
关键时刻,第一时间送达!
正文
效果展示
使用方法
TableViewAnimationKit调用各个动画的方法都为类方法,只需一行代码就可以调用。
eg:
[TableViewAnimationKit shakeAnimationWithTableView:tableView];
TableViewAnimationKit提供的动画类方法
+ (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左右各自插入。
实现代码很简单如下:
+ (void)shakeAnimationWithTableView:(UITableView *)tableView {
NSArray *cells = tableView.visibleCells;
for (int i = 0; i < cells.count; i++) {
UITableViewCell *cell = [cells objectAtIndex:i];
if (i%2 == 0) {
cell.transform = CGAffineTransformMakeTranslation(-XS_SCREEN_WIDTH,0);
}else {
cell.transform = CGAffineTransformMakeTranslation(XS_SCREEN_WIDTH,0);
}
[UIView animateWithDuration:0.4 delay:i*0.03 usingSpringWithDamping:0.75 initialSpringVelocity:1/0.75 options:0 animations:^{
cell.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {
}];
}
}
主要思路为:
获得tableview的visibleCells数组,进行遍历,对每个执行动画,不同cell的执行时间、方向有所差异,一起构成整个动画。
其他一些动画效果
后语
源码: https://github.com/alanwangmodify/TableViewAnimationKit
作者:alanwangmodify
链接:http://www.jianshu.com/p/2dc3c9e0ca3e
來源:简书
iOS开发整理发布,转载请联系作者授权
【点击成为安卓大神】
- 一行代码让你的TableView动起来-iOS动画
- 一行代码让你的TableView动起来-iOS动画
- iOS-一行代码让你的TableView动起来
- iOS开发之让你的应用“动”起来(动画)
- iOS开发系列--让你的应用“动”起来--动画
- iOS开发系列--让你的应用“动”起来--超详细的ios核心动画介绍
- iOS开发系列--让你的应用“动”起来,iOS动画
- iOS开发系列--让你的应用“动”起来--iOS动画
- Ios 让你的UITabbar上的按钮动起来
- iOS开发之让你的应用“动”起来
- iOS开发之让你的应用“动”起来
- iOS开发之让你的应用“动”起来
- iOS开发系列--让你的应用“动”起来
- iOS开发系列--让你的应用“动”起来
- iOS开发系列--让你的应用“动”起来
- iOS开发系列--让你的应用“动”起来
- iOS开发系列--让你的应用“动”起来
- iOS开发之让你的应用“动”起来
- synchronized关键字
- 常见网络攻击及处理办法
- 奔小康赚大钱 HDU
- Java字符流、字节流的超类及子类的API记录和结构图备忘
- 2017 JUST Programming Contest 3.0 D. Dice Game
- 一行代码让你的TableView动起来-iOS动画
- DTD与XSD区别
- Android 自定义 View
- Docker下,实战mongodb副本集(Replication)
- python的io 与java的io流的使用及对象的序列化
- STM32串口下载
- C++ 头文件algorithm 1——partition
- 1、面向对象的解释
- Tour HDU