zoukankan      html  css  js  c++  java
  • tableView简单的动画效果

    tableView 中一些动画效果通常都是实现willDisplayCell的方法来展示出一些动画的效果

    (1).带有3D效果的小型动态展示

    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

      

     CATransform3D rotation;

        rotation = CATransform3DMakeRotation( (-48.0*M_PI)/180, 0.0, 0.7, 0.4);

        rotation.m34 = 1.0/ -600;  //关于catransform3d m34,我会在最下方给出一些理解 

        cell.layer.shadowColor = [[UIColor blackColor]CGColor];

        cell.layer.transform = rotation;

        cell.layer.anchorPoint = CGPointMake(0.5, 0.5);

    //CATransform3DIdentity

        

        [UIView animateWithDuration:0.8 animations:^{

            cell.layer.transform = CATransform3DMakeRotation( (18.0*M_PI)/180, 0.0, 0.7, 0.4);

            cell.alpha = 1;

        } completion:^(BOOL finished) {

            [UIView beginAnimations:@"rotation" context:NULL];

            [UIView setAnimationDuration:0.8];

            cell.layer.transform = CATransform3DIdentity;

            cell.alpha = 1;

            [UIView commitAnimations];

        }];

    }

    (2).进入界面或者下拉时显示一种弹出效果的cell效果

    -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    //xy方向缩放的初始值为0.4

        cell.layer.transform = CATransform3DMakeScale(0.4, 0.4, 1);

        

    //    设置动画时间为1.25秒,xy方向缩放的最终值为1

        [UIView animateWithDuration:1.25 animations:^{

            cell.layer.transform = CATransform3DMakeScale(1, 1, 1);

        }];

     }

    (3).catransform3d m34的理解

      transform的结构如下:
      struct CATransform3D
      {
        CGFloat m11, m12, m13, m14;
        CGFloat m21, m22, m23, m24;
        CGFloat m31, m32, m33, m34;
        CGFloat m41, m42, m43, m44;
      };

      首先要实现view(layer)的透视效果(就是近大远小),是通过设置m34的:

      CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
      rotationAndPerspectiveTransform.m34 = 1.0 / -500;

      m34负责z轴方向的translation(移动),m34= -1/D,  默认值是0,也就是说D无穷大,这意味layer in projection plane(投射面)和layer in world   coordinate重合了。

      D越小透视效果越明显。
      所谓的D,是eye(观察者)到投射面的距离。

    具体详情可参考下方链接:

    http://www.jianshu.com/p/9cbf52eb39dd

  • 相关阅读:
    2016-2017-2 20155325实验二《Java面向对象程序设计》实验报告
    20155325 2016-2017-2 《Java程序设计》第8周学习总结
    20155325《Java程序设计》实验一(Java开发环境的熟悉)实验报告
    20155323 2016-2017-2《Java程序设计》课程总结
    20155323 第五次实验 网络编程与安全
    20155323课堂实践20170531
    20155323课堂实践20170524
    20155323 第四次实验 Android程序设计实验报告
    20155323课堂实践20170517
    20155323课堂实践20170510
  • 原文地址:https://www.cnblogs.com/MasterPeng/p/5695484.html
Copyright © 2011-2022 走看看