- (void)tableView:(UITableView *)tableView willDisplayCell:(CTTrainListViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
//获取UITableViewCell相对于UITabelView的坐标
CGRect rectInTableView = [tableView rectForRowAtIndexPath:indexPath];
CGRect rect = [tableView convertRect:rectInTableView toView:[tableView superview]];
//indexPath第一次加载有动画,否则没有
if(rect.origin.y >= kScreenHeight || _isScrolling ){
return;
}
cell.frame = CGRectMake(rect.origin.x, rect.origin.y+20*(indexPath.row+1), rect.size.width, rect.size.height);
cell.alpha = 0;
[UIView animateWithDuration:0.5
delay:0.1
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
cell.alpha = 1;
cell.frame = rect;
} completion:nil];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
_isScrolling = YES;
}