gpt4 book ai didi

ios - UIImage 在 self 调整 UITableViewCell 拉伸(stretch)

转载 作者:行者123 更新时间:2023-11-28 06:21:49 25 4
gpt4 key购买 nike

所以我有一个 tableview 设置,所以它显示一些带有图像的信息文本,文本可以变化,所以我设置了单元格自行更新其大小的约束,但是图像正在拉伸(stretch),如下所示,我检查内容模式是否设置为Aspect FitImage stretched

从图像中可以观察到单元格中有 3 个 View :-标题-正在拉伸(stretch)的图像-描述

我的约束设置如下:

  1. Title.top = topMargin
  2. Title.trailing = trailingMargin
  3. Title.leading = leadingMargin
  4. Title.height = 32

  5. Image.leading = leadingMargin

  6. Image.top = Title.bottom + 16
  7. bottom.margin = Image.bottom
  8. Image.width = SuperView(单元格内容).width * 0.4

  9. text.leading = image.trailing + 16

  10. trailingMargin = text.trailing
  11. bottomMargin = text.bottom
  12. text.top = topMargin + 16

如何解决此问题,使图像不会拉伸(stretch)?如果需要任何其他信息,请询问,我会添加。

谢谢-豪尔赫

最佳答案

为图像添加与其宽度相匹配的高度约束,以保持其方形纵横比。或者任何高度。只需固定高度,使其不会拉伸(stretch)。

image.height = SuperView(content of cell).width * 0.4

关于ios - UIImage 在 self 调整 UITableViewCell 拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43209398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com