中心视图与旁边的视图有关

发布于 2025-02-04 16:07:51 字数 741 浏览 3 评论 0 原文

给定以下布局:

“基本布局”

我想知道是否可以在左侧垂直将 imageView 相对于右侧的视图中心, imageView 仍将在中心(左图),而不在顶部(右图)。

我尝试将 imageView 的顶部限制为上标签及其底部到下标签,但我无法以AutoLayout会尝试使用的方式进行SE。满足两者”。尝试更改任何优先级或将约束更改为不平等,仅使 imageView 上升或向下。

Given the layout below:

Base layout

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).

desired layout
wrong layout

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". Trying to change any priority or changing the constraint to a inequality only makes the ImageView goes up or down.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俯瞰星空 2025-02-11 16:07:51

可以肯定的是,您真的是指垂直不是水平

将您的两个标签嵌入垂直堆栈视图中,并约束以堆栈视图为中心的图像视图。

另外,对于更少的约束,

  • 您的两个标签嵌入了垂直堆栈视图中,
  • 将图像视图嵌入了图像视图,并将“标签堆栈视图”嵌入水平堆栈视图中,
  • 将水平堆栈视图的对齐方式设置为中心

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...

  • Embed your two labels into a Vertical stack view
  • Embed the image view and that "labels stack view" into a Horizontal stack view
  • set the Alignment of the Horizontal stack view to Center

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文