3

I have the following table cell prototype: Table cell prototype

I would like to align the two labels in the stack view closer to each other. Something like align the "Label Table" to the bottom and align the "Label Event Location" to the top. I've tried setting the Label margin to explicit and set the margins to 0 to no avail.

Is this at all possible? Should I use UIStackView of maybe abandon it and just go for auto layout? Any help here would be greatly appriciated.

Maurits van Beusekom
  • 5,579
  • 3
  • 21
  • 35
  • 1
    Activate the Baseline Relative of the UIStackView containimg the labels (baselineRelativeArrangement = true), make sure it's axis is .Vertical and distribution is .FillEqually – nmdias Jun 22 '16 at 09:06

2 Answers2

-1

Did you use aligment of UILabel and set UIStackView to fill mode.PS: UIStackView is only available in iOS9 and later.

Lumialxk
  • 6,239
  • 6
  • 24
  • 47
  • Yes i tried setting the alignment on the UILabels. This seems to have no affect at all when they are in the stack view. I am aware of the fact stack view is only available on iOS9 and higher, appreciate the warning non the less. – Maurits van Beusekom Feb 20 '16 at 08:14
-1

I have solved the problem without using the UIStackView control. Here is how I did it (please let me know when there is a better way).

  1. Place the labels on the cell, position them 8px to the right of the orange bar
  2. Make the labels occupy the full height and width
  3. The labels are now fully overlapping each other
  4. Add the following constraints on the top label: top 0px, leading 8px, trailing 0px, bottom 15px.
  5. Add the following constraints on the bottom label: top 15px, leading 8px, trailing 0px, bottom 0px.

The trick is with adding the bottom and top constraints. Here is a screenshot of the result:

End result where the labels are centred over the full height of the view

Maurits van Beusekom
  • 5,579
  • 3
  • 21
  • 35