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

Shehryar picture Shehryar  路  7Comments

danieleggert picture danieleggert  路  3Comments

cjwirth picture cjwirth  路  4Comments

aeves313 picture aeves313  路  4Comments

cooler333 picture cooler333  路  5Comments