Reputation: 2009
I'm having a tough time getting my app to size with auto layout. I've watched just about every tutorial and messed with it for days using constraints, classes but it just isn't perfect.
I've attached a mockup of what I'm trying to do. I've created restraints but when it shrinks down one row is just smaller than the rest so it fits. If I added an equal height constraint then everything just gets pushed up in the header. I'm not using a table view, just text and the lines as images.
I'm basically just trying to keep the same ration but have the rows shrink to fit between the header and footer using a regular view.
Thanks for any help.
Upvotes: 1
Views: 1095
Reputation: 38238
I've just put together a layout that does what you want, if I'm understanding you correctly. Here's how it looks in the iPhone 4S, 5S and 6:
The views I used are:
There are two important sets of constraints to get the "stretchiness":
Basically, as long as you pin the top view to the top of the screen, the bottom view to the bottom of the screen, and give enough equal width constraints to relate all the views to each other in terms of height, Auto Layout will just figure out the actual heights for you. The only views I put any specific height constraints on (i.e. with an actual number) are the 1-pixel high views that act as the "bottom border" lines.
There's lots of other constraints going on, but they're basically pretty obvious—everything has leading and trailing space of zero to the container, zero vertical space constraints between each item and the next going down vertically. The number labels inside the views are pinned to the left-hand edge and centred vertically in their container.
It was a bit of a fiddle and Xcode crashed a couple of times, but that, sadly, is Auto Layout for you. Save early, save often.
Upvotes: 1