square / Paralayout

Paralayout is a set of simple, useful, and straightforward utilities that enable pixel-perfect layout in iOS. Your designers will love you.
https://medium.com/square-corner-blog/introducing-paralayout-d5ac09e93fb0
Apache License 2.0
790 stars 34 forks source link

Fixed spacing of 0 can be ignored between elements #126

Closed dfed closed 3 months ago

dfed commented 5 months ago

I have a distribution which is not working as expected. In the following distribution:

applyHorizontalSubviewDistribution {
    view1
    0.fixed
    view2
}

… the label and iconView end up distributed with what looks like:

applyHorizontalSubviewDistribution {
    1.flexible
    view1
    1.flexible // wrong!
    view2
    1.flexible
}

I can fix the distribution by adding explicit flexible spacers:

applyHorizontalSubviewDistribution {
    1.flexible
    view1
    0.fixed
    view2
    1.flexible
}

The original distribution works as expected if the central fixed spacer is non-zero. Discovered on master commit 420dc31e915e357fafbfe6d1f7147e2d50ed3b8f – I have not checked other versions.