原型单元中的约束

时间:2018-08-12 13:19:14

标签: ios iphone swift xcode

我是Swift和Xcode的初学者,无法理解原型单元格中的约束。

我设置了标签(“标题新闻”)在图片下方

enter image description here

但是在测试中,Label恰好位于Image的中心。

enter image description here

我做错了什么?如何正确设置图像下方的标签?

3 个答案:

答案 0 :(得分:2)

  1. 在图像视图中赋予其顶部,前导和尾随约束 超级观看。
  2. 为imageview添加高度限制(如果需要 特定高度)显示在附件图像中-enter image description here
  3. 赋予领先标签以标记其 superview
  4. 给予顶部约束以标记 imageview 。如图所示-enter image description here 表格单元格的约束看起来像-enter image description here

希望这会有所帮助。

答案 1 :(得分:1)

imageView的约束

  

前导,尾随,superView的顶部,高度(例如200)

标题限制

  

前导,尾随和底部到superView,顶部到imageView

答案 2 :(得分:1)

您可以将图像和标签垂直堆叠

,并在属性检查器上给它们留空格。

我希望它能对您有所帮助。