I have an UIView in which I want to add some 'n' buttons of varying sizes dynamically, so normally they get linearly added. Can I center align all the buttons in one go? or do I have to calculations to set the origin of each of the button ?
Here is what I have thought of if I have to do calculations:
Algorithm :
- calculate the frame with origins and add a button.
- left shift previous buttons to calculated amount
- repeat
shifting buttons of varying size becomes very difficult.
Please let me know if there are built in methods that allows me to center align all subviews of a view or should I be doing some maths.
I have stumbled upon some SOF links but seldom of any help