当选择Aspect Fit内容模式时,UIImageView在UITableView单元格中留下大量空白

时间:2019-08-10 07:04:16

标签: ios swift

enter image description here 我将UIImageView与内容模式AspectFit一起使用,但是我的网址图片的顶部和底部留有空白。

我已经尝试过使用比例填充和长宽比填充模式,但无法按要求运行。

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let row = indexPath.row

        if(row == 0){

          let cell  = tableView.dequeueReusableCell(withIdentifier: "PostNewCellIdentifier", for: indexPath) as! PostNewTableViewCell

            cell.postTitleLbl.text = commonContentList[0].commonTitle
            cell.postDateLbl.text = commonContentList[0].commonCreatedAt
           return cell


        }else if(row == 1){
            let  cell = tableView.dequeueReusableCell(withIdentifier: "PostNewSecondTableViewCellIdentifier", for: indexPath) as! PostNewSecondTableViewCell

            cell.logoURL = commonContentList[0].commonImage


             return cell
        }else if(row == 2) {

            let  cell = tableView.dequeueReusableCell(withIdentifier: "PostNewThirdTableViewCellIdentifier", for: indexPath) as! PostNewThirdTableViewCell
            cell.postDescLbl.text = postDescription

            return cell
      }
}

1 个答案:

答案 0 :(得分:0)

如果没有,则第一组尺寸包含ImageView。然后切换到缩放为填充,并选中“属性”检查器中的“ 裁剪到边界”框。