gpt4 book ai didi

ios - 更新 UITableView 单元格中的 UIImageView 透明度

转载 作者:行者123 更新时间:2023-11-29 05:00:12 25 4
gpt4 key购买 nike

我有一个 imageview 类,它是 UIImageView 类的子类,它显示在一个 UITableView 中,该 UITableView 出队ReusableCellWithIdentifier。

@interface ImageView : UIImageView {
.
.
.

当需要将图像从一张图像更新为另一张图像时,更新本身就会起作用

[self setImage:[UIImage imageWithContentsOfFile:[self resourcesDir:url]]];

但我的图像是透明的 PNG(具有相同的尺寸),因此上一个图像的一部分在更新后的图像下可见(因为单元格本身被重用)

我尝试了各种方法让 imageView 首先清除自身,但没有任何效果,这就是我尝试过的:

self.image = nil;

[self setBackgroundColor:[UIColor clearColor]];

[self setNeedsDisplay];

[self performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO];

有什么想法吗?

最佳答案

确保您没有使用 UIImageView 的新实例。它必须是同一个实例,您的代码才能正常工作。你的想法听起来应该可以正常工作。

关于ios - 更新 UITableView 单元格中的 UIImageView 透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7164509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com