Equally distribute spacing using Auto Layout visual format string

autolayout, cocoa-touch, nslayoutconstraint, uiview, user-interface

Solution

No.

However, you can do it with visual format and a manual constraint creation. Change your VFL string to:

@"|-[a(5)]->=0-[b(8)]->=0-[c(5)]-|"

This says that you're not too concerned about the actual size of the spaces between a and b, and b and c.

Now, create a constraint pinning the center of b to the center of the superview using `constraintWithItem:...` (I'm typing this on a phone so forgive me for not spelling out the whole method).

This, coupled with your flexible spacing, will give even spaces to the left and right of b.

Problem

Is it possible to equally distribute left and right space for `b` in `@"|-[a(5)]-[b(8)]-[c(5)]-|"` using visual format strings?

Original source

Related problems