0

What I'd like to do is is build constraints for a view that is stacked like this if it was built with the Visual Format Language.

"H:|-[title]-[toggle]-|"

What would be the best way to do this using SnapKit?

I'm doing this for now, but it is kind of hard to follow, since the stack setup is strewn across two closures here.

title.snp_makeConstraints { make in
  make.left.equalTo(superView)
  make.right.equalTo(toggle.left)
}

toggle.snp_makeConstraints { make in
  make.right.equalTo(toggle.superView)
}
kross
  • 403
  • 4
  • 7

1 Answers1

0

This answer may be slightly off-topic since it is not specific to SnapKit, but this is very easy to do using MarkupKit (I'm the project's author):

<LMRowView>
    <UIView id="title"/>
    <UIView id="toggle"/>
</LMRowView>

Internally, LMRowView creates constraints that are similar to what would be produced by your VFL example (H:|-[title]-[toggle]-|).

Greg Brown
  • 3,168
  • 1
  • 27
  • 37