的backgroundColor我试图从红色动画双表格单元背景颜色回原来的颜色,白色。动画效果的UITableViewCell的块动画
下面的代码是我使用的是什么。问题是它从不显示红色 - 它只是从(原始)白色动画到(动画到)白色。也就是说,如果我改变动画块中的颜色,它将动画成该颜色。
[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].backgroundColor = [UIColor redColor];
[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].backgroundColor = [UIColor redColor];
[UIView animateWithDuration:0.8 delay:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{
[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]].backgroundColor = [UIColor whiteColor];
[table cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]].backgroundColor = [UIColor whiteColor];
}
completion:^(BOOL finished) {
}];
下面的代码将按预期为表的背景,但是这不是我想要的:
table.backgroundColor = [UIColor redColor];
[UIView animateWithDuration:0.8 delay:0.2 options:UIViewAnimationOptionCurveEaseInOut animations:^{
table.backgroundColor = [UIColor clearColor];
}
completion:^(BOOL finished) {
}];
那么,为什么当我的表背景不我的手机背景动画?
对于它的价值,我有一堆其他链接的动画我在这之后对上表视图进行的,不过话说评论这些动画的时候,我还是有这个问题。
TableView单元对于它们的背景颜色有点神奇。你只能在tableView:willDisplayCell:forRowAtIndexPath方法中设置单元格的背景颜色(通过'UIView'中的'backgroundColor'属性),而不是其他任何地方。请参阅文档以获取更多信息https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006938 –