[英]Setting the size for an image in a TableViewCell
我有一張桌子,桌子的高度為90。
我想在尺寸為50x50的每一行上都有一張圖片。
我正在cellForRowAtIndexPath
執行以下操作:
cell.imageView.frame = CGRectMake(0, 0, 50, 50);
cell.imageView.clipsToBounds = YES;
cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
if (item.image){
cell.imageView.image = [item.image smallImage];
cell.imageView.alpha = 1.0f;
} else {
cell.imageView.image = [UIImage imageNamed:@"icon-greyed.png"];
cell.imageView.alpha = 0.25f;
}
但是,圖像顯示的高度為90(行的高度)。 我做錯了什么?
您將需要將UIImageView
添加到不推薦使用的cell.contentView
中,或者創建一個自定義UITableViewCell
推薦使用的cell.contentView
。 然后,您可以將UIImageView
添加到您的自定義單元中,然后將其調整為所需的尺寸。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.