PinLayout
PinLayout copied to clipboard
Attach view to different edges or use priorities
Hi! Can I use some priorities or attach anchor of the view to more than one view? I have header with attaching in top of the base view, and grey view below the header. But when my base view compressed I want compress header.
Default:
Compressed:
Code:
headerView.pin
.top()
.horizontally()
.margin(.edgeInset)
greyView.pin
.below(of: headerView)
.horizontally()
.bottom()
.minWidth(.zero)
.minHeight(.zero)
.margin(.spacer, .edgeInset, .edgeInset)
And also what am I doing wrong? I should set minimum dimensions of the grey view, cos when I compress base view a lot from correct size, greyView has previous frame (I think this is cos some computed values of the greyView frame is negative).
For example (without .minWidth(.zero).minHeight(.zero))
:
I would like to use .bottom()
for headerView
with low priority maybe.
I can use some calculations with sizeThatFits of the views, but want to solve this issue only by library with internal autoSizeThatFits of the views.