Storyboard Constraints

Help autolayout out, visually

Photo by Wojtek Mich on Unsplash

Prerequisites:

The example with a UILabel

This project is going to show how to create a UILabel with a fixed width and height, placed nicely onto the Storyboard.

Move to the storyboard

Adding the UILabel

You can access the Storyboard by selecting it in the project navigator

Adding the constraints

Finally! The heart of this article. The technique to add constraints if to control-drag from object to object.

Wait…

have you seen the little yellow dot that is on the left hand side. That’s an Interface Builder warning.

Conclusion

Adding constraints in the storyboard is a common thing you’ll need to do as an iOS developer. I hope this article has given you a little bit of a hand, and resolved any issues that you’ve got. If you want to see the completed project, download from the REPO.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store