ios - 选择拟合拟合内容模式时,UIImageView在UitableView单元格中留下了重要的空格
问题描述
我将 UIImageView 与内容模式 AspectFit 一起使用,但我的 url 图像在顶部和底部留下了空白区域。
我已经尝试过使用比例填充和方面填充模式,但它不能按要求工作。
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
}
}
解决方案
ImageView
如果你没有,首先设置大小约束。然后切换到Scale to Fill,并在 Attributes Inspector 中选中Clips to Bounds框。
推荐阅读
- c# - MongoDB选择与数组中的值匹配的记录
- kubernetes - 服务“kubernetes”已删除 - 意外删除了 kubernetes 服务
- haskell - 为什么使用 QuantifiedConstraints 来指定类型类的子类也需要子类的实例?
- java - 如何与我制作的自定义日历中的时间同步。?就像我打开日历一样,它应该显示当前日期和月份
- javascript - 滚动方法 - Javascript - 组合方法?
- android - 这里的 api 是否允许在 calculateRoute 函数中启用流量
- python-3.x - 为什么在我运行代码时已经预先选择了所有单选按钮?我尝试取消选择,但它不起作用。请
- linux - 具有相同时区但不同时间的服务器
- javascript - 如何启用 Angular 动画?
- vba - 如何将 word 宏保存为加载项