仿58同城UITableViewCell动画
之前看58同城APP有一个页面中Cell依次从右向左移动,今天试着做了下。
在做的过程中也遇到了几个小的问题,也算是注意点吧。
1.Cell出现时每个Cell的动画时间一样,导致没有依次移动的效果。
根据IndexPath来设置Cell动画时间,担心时间增大时最后面的cell会出现的很慢,想着让indexPath%20这样来解决,但决定效果不太理想, 所以就还是直接用Indexpath来设置动画时间
2.复用重新加载时cell起始点总是在TableView的(0,0)点
之前以为Cell的父视图不是tableView(具体是什么我也不清楚),设置cell动画时将Cell的Y设为0了,这就导致上面的问题,应该根据IndexPath和每个RowHeight来计算Y的位置。
3.cell再次出现时也会有动画,向上滑动时最上面的先出来,稍下面的后出来
想着让Cell动画只执行一次这样就不会导致cell动画混乱。
4.代码
//
// ViewController.m
// tableViewCell
//
// Created by City--Online on 15/11/9.
// Copyright © 2015年 City--Online. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *showedIndexPaths;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_showedIndexPaths=[[NSMutableArray alloc]init];
_tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
_tableView.delegate=self;
_tableView.dataSource=self;
_tableView.tableFooterView=[[UIView alloc]initWithFrame:CGRectZero];
_tableView.tableHeaderView=[[UIView alloc]initWithFrame:CGRectZero];
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[self.view addSubview:_tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.textLabel.text=[NSString stringWithFormat:@"123abc%ld",indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
//indexpath第一次加载的有动画 否则没有
if ([_showedIndexPaths containsObject:indexPath]) {
return;
}
else
{
[_showedIndexPaths addObject:indexPath];
cell.frame=CGRectMake(self.view.bounds.size.width, indexPath.row*[_tableView rectForRowAtIndexPath:indexPath].size.height, cell.bounds.size.width, cell.bounds.size.height);
[UIView animateWithDuration:(indexPath.row)*0.05 animations:^{
cell.frame=CGRectMake(, indexPath.row*[_tableView rectForRowAtIndexPath:indexPath].size.height, cell.bounds.size.width, cell.bounds.size.height);
}];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
5.效果


仿58同城UITableViewCell动画的更多相关文章
- gitHub-高仿58同城加载动画
导入方式: /build.gradle repositories { maven { url "https://jitpack.io" } } /app/build.gradle ...
- [MISSAJJ原创] UITableViewCell移动及翻转出现的3D动画效果[58同城cell移动效果]
2015-11-20 很喜欢在安静的状态, 听着音乐,敲着键盘, 和代码们浓情对话, 每一份代码的积累, 都让自己觉得很充实快乐!Y(^_^)Y. 看到58同城app的cell有动画移动出现的特效,很 ...
- ios loading视图动画(模仿58同城)
最近看了58同城的加载视图,感觉很不错,如下图: 所以想模仿写一个,下载58同城的app,解压,发现它用的是图片来实现的动画效果, 并不是绘制出来的,所以这就相对简单些了,其实整个动画的逻辑不复杂,无 ...
- 58 同城 iOS 客户端 iOS11 及 iPhone X 适配实践
一.前言 前段时间 WWDC 大会上苹果推出了 iOS11 系统 和 iPhone X 新机型,相信各个 iOS 团队的开发者都已经在计划新系统和新机型的适配工作了.不得不说,新系统和新机型的发布确实 ...
- jquery仿搜狐投票动画代码
体验效果:http://hovertree.com/texiao/jquery/21/ 这是一款基于jquery实现的仿搜狐投票动画特效源码,运行该源码可见VS图标首先出现在中间位置,紧接着随着投票比 ...
- 用Python写爬虫爬取58同城二手交易数据
爬了14W数据,存入Mongodb,用Charts库展示统计结果,这里展示一个示意 模块1 获取分类url列表 from bs4 import BeautifulSoup import request ...
- 58同城高性能移动Push推送平台架构演进之路
本文详细讲述58同城高性能移动Push推送平台架构演进的三个阶段,并介绍了什么是移动Push推送,为什么需要,原理和方案对比:移动Push推送第一阶段(单平台)架构如何设计:移动Push推送典型性能问 ...
- 养只爬虫当宠物(Node.js爬虫爬取58同城租房信息)
先上一个源代码吧. https://github.com/answershuto/Rental 欢迎指导交流. 效果图 搭建Node.js环境及启动服务 安装node以及npm,用express模块启 ...
- javascript仿天猫加入购物车动画效果
javascript仿天猫加入购物车动画效果 注意:首先需要声明的是:代码原思路不是我写的,是在网上找的这种效果,自己使用代码封装了下而已:代码中都有注释,我们最主要的是理解抛物线的思路及在工作中 ...
随机推荐
- easyui datagrid fit 属性
fit:true - 自适应大小,填充容器 fitColumns:true - 自动使列适应表格宽度以防止出现水平滚动.
- CheckBox使用记录
页面显示 页面代码 <div> <div><input type="checkbox" value="" class=" ...
- C# WebService调用方法
public class WebServiceHelper { /// < summary> /// 动态调用web服务 /// < ...
- golang plugin的依赖问题
golang plugin的依赖问题 此文中涉及的plugin运行环境为mac 10.14,go版本为1.11 主要是想讨论一下插件依赖的第三方库的问题. 例子是在https://github.com ...
- JAVA异常的最佳工程学实践探索
此文已由作者占金武授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 先说明一下背景: 项目日志中的Exception会被哨兵统一监控并报警 比较多的项目基于dubbo在做服务化 ...
- poj1166时钟翻转
#include<stdio.h> #define TABLE_LEN 5 const int table[10][TABLE_LEN]= {{},{1,2,4,5},{1,2,3},{2 ...
- Java学习笔记XML(3)
XML简介 XML即可扩展的标记语言.因此该语言中所有的标签都是没有预先定义的,开发者可以自己随意的指定. 目前为止所有的标记的语言都属于开源的语言.由W3C组织进行一个基本的维护. 因此大家学习这些 ...
- 删除标注关联仿dda命令DIMDISASSOCIATE
static void sk_ARXTestXDatamydimassoc(void) { // Add your code for command sk_ARXTestXData.mydimasso ...
- spring-mybatis源码追踪
启用一个扫描类 <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <propert ...
- Centos安装Ruby2.2.3
升级软件包版本 (PS:我没有升级,一是太慢了,二是不知道更新完之后是否会影响其他的应用) #升级所有包,改变软件设置和系统设置,系统版本内核都升级 yum -y update #升级所有包,不改变软 ...