PinLayout icon indicating copy to clipboard operation
PinLayout copied to clipboard

Attach view to different edges or use priorities

Open SemyonovE opened this issue 1 year ago • 0 comments

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: Screenshot 2023-05-18 at 6 36 16 PM

Compressed: Screenshot 2023-05-18 at 6 36 26 PM

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)): Screenshot 2023-05-18 at 6 39 34 PM

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.

SemyonovE avatar May 18 '23 11:05 SemyonovE