Auto Layout guide----(ii)-----Auto layout without Constraints

Source: Internet
Author: User

Auto Layout without Constraints

Automatic layout with no constraints

Stack views provide a easy-to leverage the power of Auto Layout without introducing the complexity of constraints. A single stack view defines a row or column of user interface elements. The stack view arranges these elements based on its properties.

The stack view provides a simple way to measure (leverage) the power of automatic layouts, and it does not need to introduce the complexities of individual constraints. A single stack view defines one row or column of elements for the user interface. The stack view organizes them together according to the attributes of these elements.

  • axis: (only UIStackView ) defines the stack view ' s orientation, either vertical or horizontal.

    axis: (only UIStackView ) defines the direction of the stack view, either vertically or horizontally.

  • orientation: (only NSStackView ) defines the stack view ' s orientation, either vertical or horizontal.

    Orientation: (Nsstackview only) defines the method, either vertical or horizontal, of the stack view.

  • distribution: Defines the layout of the views along the axis.

    Distribution: Defines the layout of the view along the axis.

  • alignment: Defines the layout of the perpendicular to the stack view ' axis.

    Alignment: Defines the layout of a view that is perpendicular (perpendicular) to the stack view axis.

  • spacing: Defines the space between adjacent views.

    Spacing: Defines the interval between views.

To use a stack view, in Interface Builder drag either a vertical or horizontal stack view onto the canvas. Then drag the content and drop it into the stack.

To use a stack view, drag a vertical or horizontal stack view onto the canvas in the Interface Builder (Interface builder). Then drag the content and put it into the stack.

The If an object has a intrinsic content size, it appears in the stack at that size. If It does not has an intrinsic content size, Interface Builder provides a default size. You can resize the object, and Interface Builder adds constraints to maintain its size.

If an object has a fixed content size, it does not change in size on the stack. If it does not have a fixed content size, Interface Builder will provide a default size. You can redefine the object, and Interface Builder adds a variety of constraints to maintain its size.

To further fine-tune the layout, you can modify the Stack view ' s properties using the Attributes inspector. For example, the following example uses an 8-point spacing and a Fills equally distribution.

To further fine-tune the layout, you can use the Property Inspector (Attributes inspector) to modify the properties of the stack view. For example, the following example uses a 8-point interval, and the distribution interval is the same when filling.

The stack view also bases its layout in the arranged views ' content-hugging and compression-resistance priorities. You can modify these using the Size inspector.

The layout of the stack view also depends on the content-hugging of the organized view and the anti-compression (compression-resistance) precedence. You can use size Inspetor to modify these features.

NOTE

Attention:

You can further modify the layout by adding constraints directly to the arranged views; However, want to avoid any possible conflicts:as a general rule of thumb, if a view's size defaults back to its Intri Nsic content size for a given dimension, you can safely add a constraint for that dimension. For more information in conflicting constraints, see unsatisfiable Layouts.

You can also modify the layout further by adding various constraints directly to the organized view, but avoid any possible conflicts: as a basic rule, if the size of a view is its original fixed size, you can add a constraint to that dimension with peace of mind. For more information on constraint conflicts, see unsatisfiable Layouts

Additionally, you can nest stack views inside other stacks views to build more complex layouts.

In addition, the stack view can also be nested in other stack views to build more complex layouts.

In the general, use the stack views to manage as much of your layout as possible. Resort to creating constraints if you cannot achieve your goals with stacks views alone.

For more information on using the stack views, see Uistackview class Reference or Nsstackview class reference.

In general, use a stack view whenever possible to manage your layout. You can use a variety of constraints only if you can't reach your goal with only a stack view.

NOTE

Attention:

Although the creative use of nested stacks views can produce complex user interfaces, you cannot completely escape the need for constraints. At a bare minimum, your always need constraints to define the position (and possibly the size) of the outermost stack.

Although using nested stack views creatively can generate complex user interfaces, you cannot completely escape the constraints of help. At the very least, you always need constraints to define the position of the outermost stack (or perhaps the size).

Understanding Auto Layout

Anatomy of a Constraint

Auto Layout guide----(ii)-----Auto layout without Constraints

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.