给TableViewCell添加动画

来源:互联网 发布:php eval返回值 编辑:程序博客网 时间:2024/04/29 12:25

实现TableView得到代理方法

  • (void)tableView:(UITableView )tableView willDisplayCell:(UITableViewCell )cell forRowAtIndexPath:(NSIndexPath *)indexPath;

在代理方法中实现实现如下代码:

    CATransform3D trainsform;    trainsform = CATransform3DMakeTranslation(0, 100, 0);    cell.alpha = 0;    cell.layer.transform = trainsform;    [UIView animateWithDuration:2 animations:^{        cell.alpha = 1;        cell.layer.transform = CATransform3DIdentity;    }];

实现效果是从下至上平移.

3d立体效果(不完善有BUG)

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];

相关连接参考:http://www.cocoachina.com/bbs/read.php?tid=203678

0 0
原创粉丝点击