View Layout

Use stack views to lay out the views of your interface automatically. Use Auto Layout when you require precise placement of your views.


When you design your app’s interface, you position views and other interface elements in your app’s windows and size them appropriately. However, the size and position of those views may need to change at runtime for a variety of reasons:

  • The user can resize the window containing your views.

  • Variations in the screen sizes of iOS devices (including differences between portrait and landscape orientations) require different layouts for each device and orientation.

  • Apps on iPad must adapt to cover different amounts of screen space, ranging from a third of the screen to the entire screen.

  • Language changes might require size changes for labels and other text-based views.

  • Dynamic Type allows changes to the size of the text, which affects the size of the view.

UIStackView objects adjust the position of their contained views automatically when interface dimensions change. Alternatively, Auto Layout constraints let you specify the rules that determine the size and position of the views in your interface.


First Steps


A streamlined interface for laying out a collection of views in either a column or a row.


Positioning Content Within Layout Margins

Position views so that they are not crowded by other content.

Positioning Content Relative to the Safe Area

Position views so that they are not obstructed by other content.


The relationship between two user interface objects that must be satisfied by the constraint-based layout system.


A set of methods that provide layout support and access to layout anchors.


Creates a dictionary wherein the keys are string representations of the corresponding values’ variable names.

Layout Guides


A rectangular area that can interact with Auto Layout.


A factory class for creating size-based layout constraint objects using a fluent API.



A factory class for creating layout constraint objects using a fluent API.


A factory class for creating horizontal layout constraint objects using a fluent API.


A factory class for creating vertical layout constraint objects using a fluent API.

See Also

User Interface

Views and Controls

Present your content onscreen and define the interactions allowed with that content.

View Controllers

Manage your interface using view controllers and facilitate navigation around your app's content.

Appearance Customization

Add Dark Mode support to your app, customize the appearance of bars, and use appearance proxies to modify your UI.

Animation and Haptics

Provide feedback to users using view-based animations and haptics.

Windows and Screens

Provide a container for your view hierarchies and other content.