简体   繁体   中英

How to resize UIImageView in Swift

I have an image in my UITableView cells, but for some cells, I want not to show image, so I decided to set image height size to zero (you know I cannot use Hidden=true) because of remaining blank space.

So, I tried every thing, but I couldn't resize image, here is my code, so how to resize ?

    cell!.imageImage.layer.frame = CGRectMake(0, 0, 0, 0)
    cell!.imageImage.layer.masksToBounds = true                  

I also tried:

    cell!.imageImage.frame = CGRectMake(0, 0, 0, 0)
    cell!.imageImage.layer.masksToBounds = true

So what should I do ?

如果将默认的UITableViewCellUITableViewCellStyleDefault ,则必须UITableViewCell子类并实现layoutSubviews方法,并在那里设置图像的框架。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM