Reputation: 3604
I am wondering if i can achieve this with Xcode's IB auto layout constraints, as currently i am beating my head against a wall, referring to the image below:
I have three views, and want the upper and lower to be proportional to the screen, and have the middle lock x pixels from each. I am sure i can manually do it, but am also sure that somehow the aspect ratio constraint can allow this to happen.
I am pinning the top/bottom view to sides (0), and respective top/botton (o), laying out the view i want in IB's iPad rendering so the proportions look proper, then setting aspect. Logically this makes sense to me, but it isn't working, so i suspect I am making assumptions about the aspect constraint.
Hopefully this is explained well enough to elicit a saving thought or two. thx.
Upvotes: 0
Views: 52
Reputation: 1252
I'm not sure if I understood what you mean correctly, but is that effect below you would like to achieve?
Take a look at the constraints.
Upvotes: 1
Reputation: 4373
Use equal height or width constraints to the superview and set multiplier to the percentage you want it to take. 50% would be .5. To create these in the document outline drag from the child view to the parent view. You will see the option of equal heights or widths. Choose edit on the constraint and change the multiplier from 1 to the desired number. Cheers. Or see answer How to scale height of views and postion of the views relative to the screen size using AutoLayout
Upvotes: 1