Snapkit: Question: proportional width / height

Created on 13 Feb 2015  ·  3Comments  ·  Source: SnapKit/SnapKit

Hello,

I might be overlooking something but cant figure out how to do proportional width / height constraints. I.e. view1 height is 50% of view2 height. Is this supported by Snap?

Most helpful comment

Of course, you can use dividedBy or multipliedBy which are not documented. You can find those here: Constraint.swift

view1.snp_makeConstraints { make in
    make.height.equalTo(view2).multipliedBy(0.5)
}

..or..

view1.snp_makeConstraints { make in
    make.height.equalTo(view2).dividedBy(2)
}

All 3 comments

Of course, you can use dividedBy or multipliedBy which are not documented. You can find those here: Constraint.swift

view1.snp_makeConstraints { make in
    make.height.equalTo(view2).multipliedBy(0.5)
}

..or..

view1.snp_makeConstraints { make in
    make.height.equalTo(view2).dividedBy(2)
}

Excellent! Thanks!

Glad it helped :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seljabali picture seljabali  ·  3Comments

lolgear picture lolgear  ·  5Comments

romk1n picture romk1n  ·  3Comments

phongle6893 picture phongle6893  ·  4Comments

jagdish24 picture jagdish24  ·  3Comments