UILabel重叠在UITableViewCell(Autolayout)

时间:2015-10-12 17:17:35

标签: ios uitableview autolayout

我正在制作一个带有几个元素的自定义TableViewCell,按从左到右的顺序列出如下:

  1. 用户名 - UILabel(@IBOutlet)
  2. “将要去” - UILabel(静态)
  3. 地点 - UILabel(@IBOutlet)
  4. 时间戳 - UILabel(@IBOutlet)
  5. 图片 - UIImage(@IBOutlet)
  6. 我的问题是我无法弄清楚如何设置Autolayout以便Venue(元素3)可以在重叠到Timestamp(元素4)之前截断自身。

    我可以设置Venue的宽度,这可以解决重叠问题(如果用户名很长),但如果用户名很短,它也会过早截断。请注意我不想截断用户名,因为它比场地更重要。

    我附上了一些图片以供澄清,以及说明我正在为Venue和Timestamp使用的Autolayout约束。

    在IB中:

    enter image description here

    问题:

    enter image description here

    用户名(要素3)约束:

    enter image description here

    时间戳(要素4)约束:

    enter image description here

1 个答案:

答案 0 :(得分:2)

您可以在场地标签和时间戳标签之间设置约束,使两者之间的间距始终为> = 5

我认为这将是从场地到时间戳的尾随空间限制