TableView使用CATransform3D特效动画

效果一:

在代理方法中实现:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    // CA_EXTERN CATransform3D CATransform3DTranslate (CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)  tx: 左右移动 ty: 上下移动

    transform = CATransform3DTranslate(transform, 0, 50, 0);
    cell.layer.transform = transform;
    [UIView animateWithDuration:0.5 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}

效果二:

代码:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    // CA_EXTERN CATransform3D CATransform3DTranslate (CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)  tx: 左右移动 ty: 上下移动

    transform = CATransform3DTranslate(transform, 50, 50, 0);
    cell.layer.transform = transform;
    [UIView animateWithDuration:0.5 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}

效果三:

效果四:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, M_PI_2, 0, 0, 1);
    transform = CATransform3DTranslate(transform, 0, 50, 0);
    transform = CATransform3DScale(transform, 0.0, 0.0, 0.0); //由小变大
    cell.layer.transform = transform;
    cell.layer.opacity = 0.0;

    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
        cell.layer.opacity = 1;
    }];
}

效果五:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    // CA_EXTERN CATransform3D CATransform3DRotate (CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z)
    transform = CATransform3DRotate(transform, M_PI_2, 0, 0, 1);//渐变
    // CA_EXTERN CATransform3D CATransform3DTranslate (CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)  tx: 左右移动 ty: 上下移动
    transform = CATransform3DTranslate(transform, 200, 50, 0);//左边水平移动

    transform = CATransform3DScale(transform, -0.5, 0.5, 1); // sx sy 的任意一个为负

    cell.layer.transform = transform;
    cell.layer.opacity = 0.0;

    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
        cell.layer.opacity = 1;
    }];
}

效果六:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    // CA_EXTERN CATransform3D CATransform3DRotate (CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z)
    transform = CATransform3DRotate(transform, M_PI_2, 0.5, 0.0, 0);// 变化的角度
     // CA_EXTERN CATransform3D CATransform3DTranslate (CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)  tx: 左右移动 ty: 上下移动
    transform = CATransform3DTranslate(transform, 0, 50, 0);

//  transform = CATransform3DScale(transform, 0.5, 0.0, 1); // sx sy 的任意一个为负
    transform = CATransform3DScale(transform, 0.5, 0.0, 1); // sx sy 的任意一个为负
    cell.layer.transform = transform;

    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}

效果七:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    // CA_EXTERN CATransform3D CATransform3DRotate (CATransform3D t, CGFloat angle, CGFloat x, CGFloat y, CGFloat z)
    transform = CATransform3DRotate(transform, M_PI_2, 0.5, 0.0, 0);// 变化的角度

    // CA_EXTERN CATransform3D CATransform3DTranslate (CATransform3D t, CGFloat tx, CGFloat ty, CGFloat tz)  tx: 左右移动 ty: 上下移动
    transform = CATransform3DTranslate(transform, 0, 50, 0);
    transform = CATransform3DScale(transform, 0.0, 0.5, 1); // sx sy 的任意一个为负

    cell.layer.transform = transform;
    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}

效果八:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, M_PI_2, 0.0, 0.5, 0);// 变化的角度  x = 0.5  y = 0.5
    transform = CATransform3DTranslate(transform, 0, 50, 0);
    transform = CATransform3DScale(transform, 0.5, 0.5, 1);

    cell.layer.transform = transform;
    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}

效果九:

代码: 上面代码改变 Rotate

  • transform = CATransform3DRotate(transform, M_PI_2, 0.5, 0.0, 0);// 变化的角度  x = 0.5  y = 0.5

效果十:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    CATransform3D transform = CATransform3DIdentity;
    transform = CATransform3DRotate(transform, M_PI_2, 0.0, 0.0, 1);// 变化的角度  x = 0.5  y = 0.5
    transform = CATransform3DTranslate(transform, -200, 50, 0);
    transform = CATransform3DScale(transform, 0.5, 0.0, 1);

    cell.layer.transform = transform;
    [UIView animateWithDuration:0.6 animations:^{
        cell.layer.transform = CATransform3DIdentity;
    }];
}
时间: 2024-08-06 11:54:35

TableView使用CATransform3D特效动画的相关文章

一个tableview的自带动画

最近在实习,这是最近老师叫做的项目里面的一个东西,先以为很难,做了很久也没做出来,后面老师讲了之后发现其实很简单,现在分享上来给大家. 说一下他的主要逻辑,其实就是设置了几个section ,section的headview需要自定义..存了几个字典在datasoure(也就是一个数组当中).字典里面有个bool值判断是否展开section,也就是是否添加cell进section里面.添加进去的时候tableview自带了动画所以看起来就跟上面一样了.删除同理,只是把cell移除了而已.逻辑真的

关于UI功能解锁,UI特效动画,UI tips的再思考

之前写过一篇这样的文章,但当时的思路可行性太低,最近又想了想pureMVC的消息机制,灵光一闪,似乎可以基于消息去实现三者.当然和PureMVC没多大关系,那个连UML图都相当复杂 首先所有的UI面板通过发送字符串消息来告知,是否触发了解锁检测,tips检测,动画特效.可以理解为这样的接口: AsyncResult SendUIMessage(string message); AsyncResult是我定义的一个类,专门得到异步结果.这样特效动画播放完的异步回调也直接返回了. 而除了特效以外,T

Cocos2d-x-v3中3D网格特效动画的应用

Cocos2d-x-v3中3D网格特效动画的应用 一.网格特效的使用原理 基础的动作是对节点整体进行移动,变形等操作,网格特效的原理是将节点分割成多个尺寸相同的网格,根据改变每个网格块的属性使整体节点产生3D的效果. 二.网格特效的基本用法 在cocos2d-x中,v3的版本新引入了一个类NodeGrid,专门用来包装网格的特效,示例如下:     //获取屏幕尺寸     Size visibleSize = Director::getInstance()->getVisibleSize();

CATransform3D iOS动画特效详解

关于图层的几个坐标系. 对于ios来说,坐标系的(0,0)点在左上角,就是越往下,Y值越大.越往右,X值越大. 一个图层的frame,它是position,bounds,anchorPoint和transform属性的一部分. 设置一个新的frame将会相应的改变图层的position和bounds,但是frame本身并没有保存. position:是一个CGPoint值,它指定图层相当于它父图层的位置,该值基于父图层的坐标系. bounds:是一个 CGRect值,指定图层的大小(bounds

简单tableView的cell的动画旋转

cell 的动画一般用的不多,但是简单的修改一下属性还是能把cell的出场华丽的转世一下,在代理方法willDisplayCell中设置一下layer的属性就OK了. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ //设置anchorPoint    cell.layer.anchorPoi

tableView 滑动滑出动画

简单的UITableViewCell特效 飞入飞出之类的 看了一些最近放出来的控件, 有些是关于UITableViewCell显示的特效. 也有朋友问我咋做. 就写了个简单的介绍. 1. UITableVIew需要实现 - (void)tableView:(UITableView *)tableView willDisplayCell:(TestTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath - (void)tabl

用TableView写带特效的cell

效果: 源码地址: https://github.com/YouXianMing/Special-Effect-Cell 分析: 在UIScrollView中的代理中发送广播,然后在cell中接收广播 对每一个cell进行设置 对开发有利的一种小细节: 核心源码: 控制器源码 // // ViewController.m // TableView // // Created by XianMingYou on 15/4/9. // Copyright (c) 2015年 XianMingYou.

H5特效动画中的CSS技巧

当下CSS3应用已经相当广泛,其中重要成员之一就是CSS3动画.并且,随着CSS动画的逐渐深入与普及,更复杂与细腻的动画场景也如雨后春笋般破土而出.例如上个月做的「企业QQ-新年祝福」活动: 感谢shirley帮忙录制上面的视频,虽然视频内容是手机上的显示效果,但是,这个"企业新年祝福活动"原本只针对桌面端,移动端是后来辅助增强(增加了相当于活动页面UV 5.7%的点击).而目前大多数类似页面只针对移动端,例如其他同事实现的QQ空间5.0预约页第二版: 扫码(需登录)或者链接二选一:

CATransform3D 特效详解

关于图层的几个坐标系. 对于ios来说,坐标系的(0,0)点在左上角,就是越往下,Y值越大.越往右,X值越大. 一个图层的frame,它是position,bounds,anchorPoint和transform属性的一部分. 设置一个新的frame将会相应的改变图层的position和bounds,但是frame本身并没有保存. position:是一个CGPoint值,它指定图层相当于它父图层的位置,该值基于父图层的坐标系. bounds:是一个CGRect值,指定图层的大小(bounds.