Posts

Post not yet marked as solved
10 Replies
I found a better solution to this. You can easily add 1 line to the storyboard/XiB file. I was lucky to have a previously existing constraint that I could use as a reference, so I'm sharing it with those out there that don't have that luck. This is the line I added: <constraint firstItem="w8A-AW-Z0t" firstAttribute="width" secondItem="iGR-Zz-5CD" secondAttribute="width" multiplier="1/5" id="Mwe-3A-te7"/> Where: "w8A-AW-Z0t" is the child view, "width" is self-explanatory, "iGR-Zz-5CD" is the parent view, "1/5" is whatever ratio you want to use --on this example, the child's width is a fifth of the parent's, "Mwe-3A-te7 is the id of the constraint, you put there any string you wanna come up with that follows the similar pattern "{3 chars}-{3 chars}-{3 chars}". And, of course, it must not be already used by any other existing element (Cmd+F). Just open up the storyboard/XiB file as source code. The above line must be added to the parent view. Assuming the parent has other constraints, you'll be able to see pretty easily where to add it. The order in the constraints array doesn't matter, it will work as long as you place it in the right section. Pretty simple. Hope it helps. Good luck, LucasV