0

在表格视图中,我正在添加带有动画的新单元格(到表格视图的顶部)(单元格的背景颜色从灰色变为默认白色)。一切正常,但它只对屏幕上可见的单元格进行动画处理。因此,如果显示的行数更多,它不会为其余单元格设置动画。

这是我为单元格设置动画的代码(我在我的自定义更新表格视图方法中使用它,在插入新行之后。InsertingArray 由应该动画的行的 IndexPath 组成):

for (int i=0; i<[insertingArray count]; i++)
{
    UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:[insertingArray objectAtIndex:i]];
    cell.backgroundColor = [UIColor grayColor];
    [UIView animateWithDuration:1.0
            delay: 1.0
            options: UIViewAnimationOptionCurveEaseIn
            animations:^{
            cell.backgroundColor = [UIColor whiteColor];
    }
    completion:nil];
}

那么,如何修复它并为表格视图中添加的所有行设置动画?

4

0 回答 0