使用下面的代码,我已经成功地使我的 UIImageView 在其图像中淡出。
[UIView transitionWithView:myCell.myImageView duration:2.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
myCell.myImageView.image = myImage;
} completion:NULL];
但是,当重新使用单元格时,我需要删除此图像。 重复使用时,它会显示最后一张图像(在重复使用之前显示),然后过渡到它应该是的图像,而不是从没有图像过渡到它应该是的图像。
我尝试过的:
-(void)prepareForReuse {
[super prepareForReuse];
// More is obviously needed than just setting image to nil when using a transition
self.myImageView.image = nil;
[self.myImageView setNeedsDisplay];
// but I also tried removing all animations
[self.myImageView.layer removeAllAnimations];
// and I even tried removing the sublayers, but still no success.
[self.myImageView.layer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)];
}
感谢任何帮助,但如果您不明白问题是什么,请不要回答。请改为发表评论,以便我可以在需要时更好地解释。
谢谢!
最佳答案
你可以利用回调
tableView:didEndDisplayingCell:forRowAtIndexPath:
这就是当单元格超出可见区域时调用的。
尝试在此处将图像设置为零或无图像。应该可以。
关于ios - 如何去除 UIView transitionWithView 的效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28535466/