Aastha Aastha - 1 year ago 93
iOS Question

How to setup layout constraints for a horizontal alignment of UIImageView's

I am trying to implement something like the image shown (http://i.stack.imgur.com/jKmGO.png) below using auto layout in Swift, but every time I end up with some issues. Can anyone please tell me the best way to implement auto layout for this kind of arrangement in horizontal grid for 3,4,5 or more image views.

Answer Source

Try the following steps 1) first select all of them and add constraint EQUAL WIDTH to images 2) set the leading space between left margin and first image view( let it be d) 3) Similarly set trailing space between the right margin and last imageview (let it be d) 4) Now add constraint HORIZONTAL DISTANCE(d) between all the image view e.g.


Checkout Stanford Cs193p lecture no 8. Something similar is considered which was a basic calculator with equal width and height of keys.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download