UITableViewCell的一些动画

UITableViewCell的一些动画

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    //[self leftInsertAnimation:cell];
    //[self springAnimation_1:cell];
    //[self springAnimation_2:cell];
    //[self left3DAnimation:cell];
    [self flyInAnimation:cell];
}

1、左侧插入动画

-(void) leftInsertAnimation:(UITableViewCell*)cell{
    CGPoint center = cell.center;
    CGPoint orgCenter = center;
    center.x += cell.bounds.size.width;
    cell.center = center;

    [UIView animateWithDuration:0.5 animations:^{
        cell.center = orgCenter;
    }];
}

2、弹簧效果

-(void) springAnimation_1:(UITableViewCell*)cell{
    CGPoint center = cell.center;
    CGPoint orgCenter = center;
    center.y += cell.bounds.size.height;
    cell.center = center;
    
    [UIView animateWithDuration:0.5 animations:^{
        cell.center = orgCenter;
    }];
}

3、折叠展开效果

-(void) springAnimation_2:(UITableViewCell*)cell{
    
    cell.transform = CGAffineTransformMakeTranslation(0, -80);
    
    [UIView animateWithDuration:0.5 animations:^{
        cell.transform = CGAffineTransformIdentity;
    }];
}

4、左侧3D变幻效果

-(void) left3DAnimation:(UITableViewCell*) cell{
    CATransform3D rotation;
    rotation = CATransform3DMakeRotation( (90.0*M_PI)/180, 0.0, 0.7, 0.4);
    rotation.m34 = 1.0/ -600;
    
    cell.layer.shadowColor = [[UIColor blackColor]CGColor];
    cell.layer.shadowOffset = CGSizeMake(10, 10);
    cell.alpha = 0;
    cell.layer.transform = rotation;
    cell.layer.anchorPoint = CGPointMake(0, 0.5);
    
    [UIView beginAnimations:@"rotation" context:NULL];
    [UIView setAnimationDuration:0.8];
    
    cell.layer.transform = CATransform3DIdentity;
    cell.alpha = 1;
    cell.layer.shadowOffset = CGSizeMake(0, 0);
        
    [UIView commitAnimations];
}

5、底部飞入效果

-(void) flyInAnimation:(UITableViewCell*) cell{

    cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1);
    //x和y的最终值为1
    [UIView animateWithDuration:1 animations:^{
        cell.layer.transform = CATransform3DMakeScale(1, 1, 1);
    }];
}

6、绕Z轴旋转

cell.layer.transform = CATransform3DMakeScale(0.1, 0.1, 1.0);
    [UIView animateWithDuration:0.4 animations:^{
        cell.layer.transform = CATransform3DMakeScale(1.0, 1.0, 1.0);
    }];

另:也可根据indexPath来控制旧数据和新数据是否动画,自己可根据需求自定义动画效果

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、简介 <<UITableView(或简单地说,表视图)的一个实例是用于显示和编辑分层列出的信息的一种手段 <<...
    无邪8阅读 13,687评论 3 3
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,733评论 4 61
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 12,993评论 3 38
  • 使用一个list包裹着button和一个div,点击button后才显示div里面的内容,加了点特效(渐变)让他变...
    undefind33阅读 3,440评论 0 0
  • 1 我在联想当大客户经理做销售的时候,遇到公家单位的这类型客户感觉还挺好谈的,因为公家单位购买联想的电脑和服务器都...
    王仲海阅读 3,736评论 1 2

友情链接更多精彩内容