#pragma mark=====tableview delegate===== - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ /** * cell从左向右移动出现动画 */ //只在最后一行Cell才出现动画 // if ([self.tableView.indexPathsForVisibleRows indexOfObject:indexPath]) { // // cell.frame = CGRectMake(-CGRectGetWidth(cell.bounds), cell.frame.origin.y, CGRectGetWidth(cell.bounds), CGRectGetHeight(cell.bounds)); // cell.alpha = 0.f; // // // [UIView animateWithDuration:0.5f // delay: 0.1 // options:UIViewAnimationOptionCurveEaseOut // animations:^{ // cell.alpha = 1.f; // cell.frame = CGRectMake(0.f, cell.frame.origin.y, CGRectGetWidth(cell.bounds), CGRectGetHeight(cell.bounds)); // } // completion:nil]; // } /** * cell 3D动画 */ NSLog(@"indexPathsForVisibleRows===%lu====%lu",[self.tableView.indexPathsForVisibleRows indexOfObject:indexPath],self.tableView.indexPathsForVisibleRows.count); if ([self.tableView.indexPathsForVisibleRows indexOfObject:indexPath]) { //旋转 CATransform3D rotation; rotation = CATransform3DMakeRotation( (90.0*M_PI)/180, 0.0, 0.7, 0.4); rotation.m34 = 1.0/ -600; /*CATransform3DMakeTranslation (参数: tx::x平移 ty:y平移 tz:z平移) 从左向右移动(-100, 0, 0) 从下向上移动(0, 200, 0) 从右下向左上移动(100, 100, 0) 从上往下掉落下来(0, -200, 0) */ //移动 CATransform3D translate = CATransform3DMakeTranslation(0, 200, 0); cell.layer.shadowColor = [[UIColor blackColor]CGColor]; cell.layer.shadowOffset = CGSizeMake(10, 10); cell.alpha = 0.0f; cell.layer.transform = translate; [UIView beginAnimations:@"translate" context:NULL]; [UIView setAnimationDuration:0.5f]; cell.layer.transform = CATransform3DIdentity; cell.alpha = 1.0f; cell.layer.shadowOffset = CGSizeMake(0, 0); [UIView commitAnimations]; } }
[MISSAJJ原创] UITableViewCell移动及翻转出现的3D动画效果
原文:http://www.cnblogs.com/missajj/p/4979078.html