[英]Center View vertically in relation to the Views next to it
Given the layout below:鉴于以下布局:
I wanted to know if it's possible to center vertically the ImageView
on the left in relation to the views on the right so that, if any of the labels grow, the ImageView
would still be on the center (left image) and not on top (right image).我想知道是否可以将左侧的
ImageView
相对于右侧的视图垂直居中,这样,如果任何标签增长, ImageView
仍将位于中心(左图)而不是顶部(右图)。
I tried constraining the ImageView
's top to the upper label and its bottom to the lower label but I haven't been able to se in a way that autolayout would try to "satisfy both".我尝试将
ImageView
的顶部约束到上标签,将其底部约束到下标签,但我无法以自动布局尝试“同时满足两者”的方式进行设置。 Trying to change any priority or changing the constraint to a inequality only makes the ImageView
goes up or down.尝试更改任何优先级或将约束更改为不等式只会使
ImageView
上升或下降。
Pretty sure you really mean Vertically not Horizontally ?很确定你真的是指垂直而不是水平?
Embed your two labels into a Vertical stack view, and constrain the image view centered to the stack view.将您的两个标签嵌入到垂直堆栈视图中,并将图像视图限制在堆栈视图的中心。
Alternatively, for even fewer constraints needed...或者,对于需要更少的约束......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.