顶部如何停止在StackView中安排子视图剪切

问题描述 投票:-1回答:1

我在stackView中有三个排列的子视图,如下所示:我的“记录”标签和“ 00:00:00”标签的底部和顶部被剪裁。我不想要

a red horizontal StackView with a Square red view , a record label and a timer label where Record Label and Timer Label are clipped by a little bit from bottom and top

对于红色方块的约束:高度= 10像素宽度= 10px

“ Rec”和“ 00:00:00”标签的约束-无

StackView的约束:'在安全区域内垂直居中尾随空格到安全区域30px

[请忽略白色背景视图,它在那里,所以我可以显示标签的剪裁..它没有任何约束。

i希望stackViews高度由“ Rec”或“ 00:00:00”标签的固有内容大小决定。以较高者为准。

ios swift autolayout ui-design
1个回答
0
投票

您可能需要为stackView指定对齐方式。如果使用情节提要,请检查stackView的“属性”检查器。指定“中心”很可能会满足您的需求。只是不要指定“填充”。

enter image description here

如果您以编程方式配置stackView,那么您所需要做的就是以这种方式设置alignment属性:

stackView.alignment = .center
© www.soinside.com 2019 - 2024. All rights reserved.