之前看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动画的更多相关文章

  1. gitHub-高仿58同城加载动画

    导入方式: /build.gradle repositories { maven { url "https://jitpack.io" } } /app/build.gradle ...

  2. [MISSAJJ原创] UITableViewCell移动及翻转出现的3D动画效果[58同城cell移动效果]

    2015-11-20 很喜欢在安静的状态, 听着音乐,敲着键盘, 和代码们浓情对话, 每一份代码的积累, 都让自己觉得很充实快乐!Y(^_^)Y. 看到58同城app的cell有动画移动出现的特效,很 ...

  3. ios loading视图动画(模仿58同城)

    最近看了58同城的加载视图,感觉很不错,如下图: 所以想模仿写一个,下载58同城的app,解压,发现它用的是图片来实现的动画效果, 并不是绘制出来的,所以这就相对简单些了,其实整个动画的逻辑不复杂,无 ...

  4. 58 同城 iOS 客户端 iOS11 及 iPhone X 适配实践

    一.前言 前段时间 WWDC 大会上苹果推出了 iOS11 系统 和 iPhone X 新机型,相信各个 iOS 团队的开发者都已经在计划新系统和新机型的适配工作了.不得不说,新系统和新机型的发布确实 ...

  5. jquery仿搜狐投票动画代码

    体验效果:http://hovertree.com/texiao/jquery/21/ 这是一款基于jquery实现的仿搜狐投票动画特效源码,运行该源码可见VS图标首先出现在中间位置,紧接着随着投票比 ...

  6. 用Python写爬虫爬取58同城二手交易数据

    爬了14W数据,存入Mongodb,用Charts库展示统计结果,这里展示一个示意 模块1 获取分类url列表 from bs4 import BeautifulSoup import request ...

  7. 58同城高性能移动Push推送平台架构演进之路

    本文详细讲述58同城高性能移动Push推送平台架构演进的三个阶段,并介绍了什么是移动Push推送,为什么需要,原理和方案对比:移动Push推送第一阶段(单平台)架构如何设计:移动Push推送典型性能问 ...

  8. 养只爬虫当宠物(Node.js爬虫爬取58同城租房信息)

    先上一个源代码吧. https://github.com/answershuto/Rental 欢迎指导交流. 效果图 搭建Node.js环境及启动服务 安装node以及npm,用express模块启 ...

  9. javascript仿天猫加入购物车动画效果

    javascript仿天猫加入购物车动画效果   注意:首先需要声明的是:代码原思路不是我写的,是在网上找的这种效果,自己使用代码封装了下而已:代码中都有注释,我们最主要的是理解抛物线的思路及在工作中 ...

随机推荐

  1. leetcode 最长公共前缀

    编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串"". 示例 1: 输入: ["flower","flow" ...

  2. NET Core 拓展方法和中间件集合(支持NET Core2.0+)

    # Pure.NETCoreExtentensions https://github.com/purestackorg/Pure.NETCoreExtensions NET Core 拓展方法和中间件 ...

  3. indows 2008 r2/做了SPS2007---2013后,发现添加原来域中的域组添加不上

    根据上次的网络包的分析, 我们在AD中找到了wtc-beijing-it的组, 不过在SharePoint日志中我们没有发现搜索成功的记录. - SearchResultEntry: CN=WTC-B ...

  4. RabbitMq初探——消息分发

    消息分发 前言 我们在用到消息队列的场景,一般是处理逻辑复杂,耗时,所以将同步改为异步处理,接入队列,下游处理耗时任务. 队列消息数量很大,且下游worker进程(消费者)处理耗时长,所以就有了任务的 ...

  5. python网络编程--协程

      1.协程 协程:是单线程下的并发,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程,即协程是由用户程序自己控制调度的.. 需要强调的是: 1. pyt ...

  6. 数据库访问接口(ODBC、OLE DB、ADO)

    最近在学C#的数据库编程,对于数据库接口技术这块的知识一直比较模糊,网上查了不少资料,看了几天还是朦朦胧胧的,只能做些笔记再研究了. 我们都知道,“数据库”是指一组相关信息的集合,最早的计算机应用之一 ...

  7. 【Oracle 12c】最新CUUG OCP-071考试题库(54题)

    54.(12-15) choose the best answer: View the Exhibit and examine the structure of the ORDER_ITEMS and ...

  8. 替代iframe新逻辑

    使用ajax请求.下面是代码逻辑 $.ajax({ url:url, type:'get', dataType: "text", success:function(msg){ $( ...

  9. (转)Javascript模块化编程(三):Require.js的用法

    转自 ruanyifeng 系列目录: Javascript模块化编程(一):模块的写法 Javascript模块化编程(二):AMD规范 Javascript模块化编程(三):Require.js的 ...

  10. [redis]复制机制,调优,故障排查

    在redis的安装目录下首先启动一个redis服务,使用默认的配置文件,作为主服务 ubuntu@slave1:~/redis2$ ./redis-server ./redis.conf & ...