iOS-一行代码让你的TableView动起来
2017-09-11 17:04
381 查看
最近看到的一个不错的demo,让tableView进入添加动画效果
UITableView 是iOS日常开发中经常使用到的控件。tableView的普通展示效果比较生硬,为了提升APP的活力,提升体验,我们可以对根据tableView的特点,操作Cell实现一些动画效果。
转自版主:https://juejin.im/post/59b11f606fb9a024a27c2a69
Github地址:https://github.com/alanwangmodify/TableViewAnimationKit
等等总共十多种动画效果…我就不一一放上来了
二、使用方法
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 {
}
主要思路为:
获得tableview的visibleCells数组,进行遍历,对每个执行动画,不同cell的执行时间、方向有所差异,一起构成整个动画。
帮版主推荐一下Github,有兴趣的帮他点个star呗~
也可以为我这个搬运工点个赞哦~谢谢��
Github地址:https://github.com/alanwangmodify/TableViewAnimationKit
UITableView 是iOS日常开发中经常使用到的控件。tableView的普通展示效果比较生硬,为了提升APP的活力,提升体验,我们可以对根据tableView的特点,操作Cell实现一些动画效果。
转自版主:https://juejin.im/post/59b11f606fb9a024a27c2a69
Github地址:https://github.com/alanwangmodify/TableViewAnimationKit
正文
一、效果展示:等等总共十多种动画效果…我就不一一放上来了
二、使用方法
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的执行时间、方向有所差异,一起构成整个动画。
帮版主推荐一下Github,有兴趣的帮他点个star呗~
也可以为我这个搬运工点个赞哦~谢谢��
Github地址:https://github.com/alanwangmodify/TableViewAnimationKit
相关文章推荐
- 一行代码让你的TableView动起来-iOS动画
- 一行代码让你的TableView动起来-iOS动画
- iOS开发tableView中如何使headView与上边岩向下偏移,一行代码就可以搞定
- iOS下用一行代码实现tableview(collectionview)的parallax效果
- iOS开发中tableView中的单独刷新一行或者是某一个Section
- 【代码笔记】iOS-TableViewOfTwoSecton
- iOS tableview 选中一行后,不显示选中颜色
- iOS 刷新tableView的某一行的row的时候,row的高度增加,数据也增加。
- iOS tableView实现单选和多选的实例代码
- TableView 去掉多余行数、IOS最后一行Cell系统分割线顶头
- Tableview最后一行无法显示或者显示不全的问题IOS
- IOS开发之tableview只选中一行
- IOSTableView 滚动到最后一行或某一行
- iOS开发:代码通用性以及其规范 第二篇(猜想iOS中实现TableView内部设计思路(附代码),以类似的思想实现一个通用的进度条)
- iOS之设置tableView背景图片/让UITableView自动滑动(定位)到某一行cell
- 【代码笔记】iOS-UIScrollerView里有两个tableView
- iOS - TableView 去掉多余行数以及最后一行Cell分割线的处理
- iOS tableView移除某一行的分割线 让分割线宽度为整个cell的宽度
- IOS 整理tableview的代码
- iOS tableView滚动到最后一行