Material: Layout - constraint to another view

Created on 1 Sep 2018  路  5Comments  路  Source: CosmicMind/Material

Hello,

it's a pretty basic question but I can't find an answer.
I have two labels, both children of the same view.

I set up the first label like this:
view.layout(firstLabel).top(100).right(10).left(10)

How do I set up the secondLabel so that it's 30 pixels below the bottom edge of the firstLabel?

Using standard autolayout syntax I would write it like this:

self.view.addConstraint(
    NSLayoutConstraint(
        item: secondLabel,
        attribute: .Top,
        relatedBy: .Equal,
        toItem: firstLabel,
        attribute: .Bottom,
        multiplier: 1.0,
        constant: 0
    ))

Is there a way to do that by using Material?

Thanks!

enhancement feature request help wanted material

All 5 comments

@davidevincenzi Hey! Thank you for sharing your issue with us. It seems there isn't any way to achieve that using Material's Layout system. We will probably rework it to add support for that. Thank you!

@OrkhanAlikhanov thanks a lot :)

@OrkhanAlikhanov let's move this to a feature request, and I do believe it has great value in our Layout system. Thanks guys!

Hey @davidevincenzi! It's coming in #1185!

With new update you can achieve what you asked in this issue:

view.layout(firstLabel).top(100).right(10).left(10)
view.layout(secondLabel)
      .top(firstLabel.layout.bottom, 30)
      .leftRight(firstLabel.layout.leftRight)

Wow! Thank you guys, I love this library!
馃憤馃憤馃憤

Was this page helpful?
0 / 5 - 0 ratings