一行代码让你的TableView动起来-iOS动画
2017-10-07 00:00
471 查看
点击上方“[b]iOS开发[/b]”,选择“置顶公众号”
关键时刻,第一时间送达!
正文
效果展示
使用方法
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开发整理发布,转载请联系作者授权
【点击成为安卓大神】
关键时刻,第一时间送达!
正文
效果展示
使用方法
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动画
- iOS-一行代码让你的TableView动起来
- iOS开发tableView中如何使headView与上边岩向下偏移,一行代码就可以搞定
- iOS开发-给TableView或者CollectionView的cell添加简单动画,很方便,直接粘代码即可
- iOS下用一行代码实现tableview(collectionview)的parallax效果
- 【代码笔记】iOS-TableViewOfTwoSecton
- iOS开发-OC之知识树,知识点(包括对象、Block、消息转发、GCD、运行时、runloop、动画、Push、KVO、tableview,UIViewController、提交AppStore)
- iOS tableView滚动到最后一行
- iOS tableView 删除某一行或某一组之后界面更新问题
- iOS中tableview 两级cell的展开与收回的示例代码
- 一行代码实现自定义转场动画--iOS自定义转场动画集
- iOS 刷新tableView的某一行的row的时候,row的高度增加,数据也增加。
- iOS 0行代码实现 TableView 无数据时展示占位视图
- iOS实现TableView中Cell出现时弹出动画
- iOS - TableView 去掉多余行数以及最后一行Cell分割线的处理
- TableView 去掉多余行数、IOS最后一行Cell系统分割线顶头
- 【代码笔记】iOS-TableViewOfTwoSecton
- 在有TableView的页面一行代码收起键盘
- IOS Tableview删除-一行和多行
- Tableview最后一行无法显示或者显示不全的问题IOS