nicklockwood / layout

A declarative UI framework for iOS
MIT License
2.23k stars 97 forks source link

Bottom property of view referenced through id is wrong with new Layout system #138

Closed TwunTee closed 6 years ago

TwunTee commented 6 years ago

I am using the new layout system using legacy layout = false. When i am using previous.bottom the view gets the value properly but if i access the bottom property of the view through id reference like #viewId.bottom the value is wrong, other properties like left and top seem to work fine

nicklockwood commented 6 years ago

I'm not 100% sure this is a bug. The value returned by bottom is context-dependent, because if you set top="previous.bottom" on a view then you want bottom to be the absolute position relative to the containing view, but if you set bottom="previous.bottom" then you want it to be the exact value you specified in the expression.

Can you show me the context in which you are using it?

TwunTee commented 6 years ago

I am trying to create a layout like

Title
Subtitle

The layout code is

<UILabel id="title" top="parent.bottom" text="Title"/>
<UILabel id="subTitle" top="#title.bottom" text="SubTitle"/>

In the above code subTitle aligns on the top instead of bottom of title but if i use previous.bottom it gets aligned correctly

<UILabel id="title" top="parent.bottom" text="Title"/>
<UILabel id="subTitle" top="previous.bottom" text="SubTitle"/>

If I use legacy layout both work as they should ie subTitle gets aligned at the bottom of title.

nicklockwood commented 6 years ago

@TwunTee I've pushed a fix to the develop branch.

nicklockwood commented 6 years ago

@TwunTee the fix has landed in version 0.6.29. Thanks for reporting it!