CATransform3D动画实例

在项目中,经常要做动画效果,比如我最近项目中做3D旋转的动画,在某一个cell中对其进行旋转主要用到的就是CATransform3D里面的

CATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x,  CGFloat y, CGFloat z) 

// zhangqing  cell 翻转动画 重置热词中

-(void)animationRefreshCellInfo:(UISearchLabelCell_Iphone *)cell arrData:(NSMutableArray *)arr{

    [cell setHotWordCellInfo:nil lastArrCount:lastHotWordsCout];

    CATransform3D transform;

    transform = CATransform3DMakeRotation( (180.0*M_PI)/180, 0, 1, 0);

    transform.m34 = 1.0/ -600;

    

    //定义cell的初始状态

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

    cell.layer.shadowOffset = CGSizeMake(10, 10);

    cell.alpha =1;

    cell.layer.transform = transform;

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

    

    //定义cell的最终状态,并提交动画

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

    [UIView setAnimationDuration:0.8];

    cell.layer.transform = CATransform3DIdentity;

    cell.alpha =1;

    cell.layer.shadowOffset = CGSizeMake(0, 0);

    cell.frame = CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height);

    [UIView commitAnimations];

    __block UISearchLabelCell_Iphone *tmpCell=cell;

    [self performBlock:^{

        [tmpCell setHotWordCellInfo:arr lastArrCount:lastHotWordsCout];

    } afterDelay:0.4];

    isResetTapped=NO;

    lastHotWordsCout=[arr count];

}


//zhangqing

- (void)performBlock:(void (^)(void))block afterDelay:(NSTimeInterval)delay{

    block = [[block copy] autorelease];

    [self performSelector:@selector(fireBlockAfterDelay:)

                          withObject:block

                            afterDelay:delay];

}

//zhangqing

- (void)fireBlockAfterDelay:(void (^)(void))block {

    block();

}

其中调用这个3D旋转的函数同样贴出来,以供以后参考

//zhangqing  重置热词事件

-(void)tappedResetHotWord:(id)sender{

    NSMutableArray *arr=[self setHotWordsShowInTableView:sender];

    dataResetCout++;

    isResetTapped=YES;

    if (IS_PHONE) {

        NSIndexPath *index=[NSIndexPath indexPathForRow:0 inSection:0];

        UISearchLabelCell_Iphone *cell=(UISearchLabelCell_Iphone *)[_myTableView cellForRowAtIndexPath:index];

        [self animationRefreshCellInfo:cell arrData:arr];

        //    [self reloadMyTableViewForRow:0 section:0];

    }else{

        [hotwordsDataTable animationRefreshCellInfo:arr];

        isResetTapped=NO;

    }

   

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值