我想要达到的目标:
Custom View 1
aligned at the top
fixed height = 20px
width = window width
Horizontal Split View
just below the custom view
width = window width
height = as large as possible
Custom View 2
aligned at the bottom
fixed height = 20px
width = window width
这是一个非常简单的布局:窗口顶部和底部的页眉和页脚,以及中间的拆分视图,左侧和右侧的一些内容应随窗口调整大小。但是,Apple 设计的自动布局管理器非常糟糕,我似乎无法让它工作。(我已经摸索了大约三个小时了!)
问题是:一旦我给自定义视图一个固定的高度,窗口高度就被锁定了,我不能再垂直调整它的大小了。我正在尝试使用以下限制来做到这一点:
Custom View 1
Constraints
height = 20px
Custom View 2
height = 20px
Constraints
Leading horiz space from Custom View 1 to Superview = 0
Leading horiz space from Custom View 2 to Superview = 0
Leading horiz space from Split View to Superview = 0
Trailing horiz space from Custom View 1 to Superview = 0
Trailing horiz space from Custom View 2 to Superview = 0
Trailing horiz space from Split View to Superview = 0
Top vert space between Custom View 1 and Superview = 0
Vert space between Custom View 1 and Split View = 0
Vert space between Custom View 2 and Split View = 0
Bottom vert space between Custom View 2 and Superview = 0
Top vert space between Custom View 2 and Superview = 344px (!)
最后一行是Xcode加的,删不掉。当然,这是负责固定垂直布局的。我怎样才能摆脱它???