How to use AutoLayout to position UIButtons in horizontal lines?
- by thomers
I need to create a couple of UIButtons programmatically in my app (iOS 6.0 and above).
Each button should have the optimal width to display button label text (of various lenghts).
I want to display the buttons in a "wrap around" style: Starting from the left edge, each button should be positioned next to each other horizontally (in a defined order), and if a button does not fit in the current "line", it should start a new line on the left edge below the previous line.
I could manually calculate the frame of each button in my code, but should I use AutoLayout (with programmatically creates NSLayoutConstraints) instead? How exactly would I need to set it up?