Search code examples
pixate

Center a View with Pixate


How would I vertically center a view with Pixate?

If I was styling a web element I would do something like this:

element {
    margin: 0 auto;
}

Pixate apparently does not have margin but you can use left and right to specify the position from neighbor elements.

So I thought it could be something like this:

element {
    left: auto;
    right: auto;
}

But that does not work. The view stays in the upper left corner of the screen.

Is there a way to do this without using aboslute pixel coordinates which I'd like to avoid?


Solution

  • As far as I know, the only ways to dynamically center a view are:

    1. Auto Layout constraints
    2. Springs and struts (if you're not using Auto Layout)
    3. Dynamic, mathematical placement of the view using CGRect

    I don't believe Pixate offers any view placement options.