zoukankan      html  css  js  c++  java
  • tableView 滑动滑出动画

    简单的UITableViewCell特效 飞入飞出之类的  

     
     
    看了一些最近放出来的控件, 有些是关于UITableViewCell显示的特效.

    也有朋友问我咋做. 就写了个简单的介绍.

    1. UITableVIew需要实现 - (void)tableView:(UITableView *)tableView willDisplayCell:(TestTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
    - (void)tableView:(UITableView *)tableView willDisplayCell:(TestTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        [cell animationForIndexPath:indexPath];
    }
    
    2. UITableViewCell需要实现 - (void)animationForIndexPath:(NSIndexPath *)indexPath
    - (void)animationForIndexPath:(NSIndexPath *)indexPath {
        int row = indexPath.row;
        float radians = (120 + row*30)%360;
        radians = 20;
        CALayer *layer = [[self.layer sublayers] objectAtIndex:0];
    
        // Rotation Animation
        CABasicAnimation *animation  = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
        animation.fromValue =@DEGREES_TO_RADIANS(radians);
        animation.toValue = @DEGREES_TO_RADIANS(0);
        
        // Opacity Animation;
        CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
        fadeAnimation.fromValue = @0.1f;
        fadeAnimation.toValue = @1.f;
        
        // Translation Animation
        CABasicAnimation *translationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
        ;
        translationAnimation.fromValue = @(-300.f * ((indexPath.row%2 == 0) ? -1: 1));
        translationAnimation.toValue = @0.f;
        
        
        CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
        animationGroup.duration = 0.4f;
        animationGroup.animations = @[animation,fadeAnimation,translationAnimation];
        animationGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        [layer addAnimation:animationGroup forKey:@"spinAnimation"];
    }
    


    3. 对应的宏
    #define DEGREES_TO_RADIANS(d) (d * M_PI / 180)
    
  • 相关阅读:
    阿里云 CDN+OSS 解决方案
    一次完整的HTTP请求过程
    apache多站点配置中ServerAlias什么意思
    legend3---apache配置https
    legend3---Fiddler如何抓手机app的包
    Fiddler:增加IP列
    http请求报文格式和响应报文格式
    http请求头中Referer的含义和作用
    Chrome保存的HAR文件怎么打开
    Android Studio 错误 Duplicate files copied in APK META-INF/LICENSE.txt
  • 原文地址:https://www.cnblogs.com/zhangwei/p/4953190.html
Copyright © 2011-2022 走看看