From the course: iOS Development: Auto Layout Programmatically

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The Auto Layout notation

The Auto Layout notation - iOS Tutorial

From the course: iOS Development: Auto Layout Programmatically

Start my 1-month free trial

The Auto Layout notation

- [Instructor] In the challenge, you wrote down all those constraints graphically. Apple documentation and Xcode has its own notation for writing them down. Since you'll see it around, and they make it easier to describe things in comments, let's discuss this notation. Apple uses algebra to describe Auto Layout constraints in the form of a linear equation. So we have view1.attribute equals view2 did attribute times a multiplier plus a constant. I haven't talked about the multiplier yet, so we're gonna ignore it, and assume it is always one for now. That changes the equation, since one really doesn't do anything to this. You equate the view you're placing as V1, and the reference as V2. The space between them is constant. For example, let's use some solutions from the challenge. Pinning the image view to the top of the view is label.top equals view.top plus 20. My attributes are those edges that I had earlier. Now, I'm gonna be using all this as comments as I write constraints. So, I'm…

Contents