Skip to content

Attach view to different edges or use priorities #270

Open
@SemyonovE

Description

@SemyonovE

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions