Jamie
Jamie

Reputation: 3051

Center UIImage vertically in Stack View

I've a stackview with an image and another stackview. This sub stackview contains two labels, the username and the tweet text. The tweet text may contain multiple lines.

I'd like the image to be centered vertically within the stackview. If I add a vertically align constraint to the UIImage the stackview takes the height of the image and truncates the twitter text.

Is it possible to vertically align the fixed size image vertically in the stackview without the tweet body being truncated with auto-layout? Or has this be done programmatically?

Cell

Image of the table cell

Constraints

Constraints

Upvotes: 1

Views: 2193

Answers (1)

Milan Nosáľ
Milan Nosáľ

Reputation: 19757

Try setting stack.alignment = .center, if the view is in stack, you should modify the stack properties, and not the UIView's.

Upvotes: 4

Related Questions