簡體   English   中英

如何在Swift中調整UIImageView的大小

[英]How to resize UIImageView in Swift

我的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

所以我該怎么做 ?

如果將默認的UITableViewCellUITableViewCellStyleDefault ,則必須UITableViewCell子類並實現layoutSubviews方法,並在那里設置圖像的框架。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM