简体   繁体   中英

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

表格单元格的图像

Constraints

约束条件

尝试设置stack.alignment = .center ,如果视图在堆栈中,则应修改堆栈属性,而不是UIView的属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM