3 ms·
Autolayout is really nice once you figure out what it's good for. And it's certainly not good for everything. Making a keyboard? Don't even bother. Too brittle
by archagon 11y ago
Autolayout is really nice once you figure out what it's good for. And it's certainly not good for everything.
Making a keyboard? Don't even bother. Too brittle, too slow.
Making something with dynamically-loading views? Probably not a good idea. Too unpredictable.
Trying to animate something fancy? Just change the frames directly. Doing it through an intermediary system is just too finnicky.
But the other day, I was designing a toolbar for my app. I needed floating menu buttons all along the top of the screen. Whenever a menu opened, it would grow horizontally and vertically; any existing menu buttons along its edges had to slide out of the way accordingly, or shrink if they hit the edge of the screen (with the distance between menu buttons being paramount). The specifics of the menu's expanded dimensions were left to the menu controller itself, and they could change at any time. For this, autolayout was absolutely the perfect tool for the job.
Whenever you have a small, finite set of static elements that can push each other around, autolayout makes things a lot simpler.
(The programmatic interface is just awful, though, and the visual formatting language doesn't do enough.)