我的 UITableView 单元格中有一个图像,但对于某些单元格,我不想显示图像,所以我决定将图像高度大小设置为零(你知道我不能使用 Hidden=true),因为剩余的空白空间。
所以,我尝试了所有方法,但我无法调整图像大小,这是我的代码,那么如何调整大小呢?
cell!.imageImage.layer.frame = CGRectMake(0, 0, 0, 0)
cell!.imageImage.layer.masksToBounds = true
我也试过:
cell!.imageImage.frame = CGRectMake(0, 0, 0, 0)
cell!.imageImage.layer.masksToBounds = true
那我该怎么办呢?
最佳答案
如果您使用默认的 UITableViewCell
和 UITableViewCellStyleDefault
,您必须子类化 UITableViewCell
并实现 layoutSubviews
方法,并在那里设置图像的框架。
关于ios - 如何在 Swift 中调整 UIImageView 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26424039/