iOS 6 Tutorial Auto Layout pt2 – Constraints Xcode 4.5

Learn Xcode 4.2 Tutorial iOS iPad iPhone 1.1 Introduction to Xcode

iOS 6 Tutorial Auto Layout pt1 – Constraints Xcode 4.5

Auto layout is one of the latest Xcode improvements to maintain objects on differing screen sizes and orientations. Apple has once again simplified the development of applications through their impressive integrated development environment – Xcode 4.5. In this tutorial we detail the pinning relationships between objects and the associated views.

Note: Auto layout can only be used with iOS 6. It is not supported with previous operating systems.

Video Tutorial


When you use Interface Builder to design an OS X user interface, you need to specify what happens to the placement of views when the user resizes the window. Prior to OS X v10.7, you did this by setting the springs and struts in the Size inspector’s autoresizing mask for each view. Now you can use Auto Layout to specify this resizing behavior. Auto Layout is a complete replacement for the autoresizing mask.

Auto Layout uses relationships called constraints to govern the layout of objects in a user interface. Interface Builder adds constraints to each object so that resizing “just works” the way you expect. As you make changes to the layout, Interface Builder automatically adds and removes constraints based on the new layout. When you select an object, Interface Builder shows the object’s constraints. In the figure below, the blue lines represent constraints on the position and size of the selected text field.

You can add your own constraints to any object or to a pair of objects. A constraint that you add yourself is called a user constraint. To add a user constraint, select one or more objects and choose either Add Constraint or Alignment from the Editor menu.

Every constraint has a set of attributes. For example, all constraints have a priority in the range 1-1000. To edit a constraint’s attributes, you select the constraint and use the Attributes inspector.

Note: Auto layout can only be used with iOS 6. It is not supported with previous operating systems.

follow us:


Download Xcode

Author: jake

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>