IOS 9 Interface Adaptation: A new feature of Xcode 7 Uistackview

Source: Internet
Author: User

Objective

Adaptation, adaptation, layout These keywords have been accompanied by iOS development, from the previous single-size screen, to the current multi-size screen, Apple has been working to let developers as little as possible to spend too much effort on these things, so Apple introduced the auto layout feature in 2012, 2014 also launched the Adaptive Layout, Size classes,2015 and launched the stack View. None of this is a tool for our developers to adapt. Today let's see what StackView is all about.

Note: The sample development environment is XCODE7 Beta 2

Let's take a look at the following common layout:

This is a very common burger layout, and if we need to adapt it to different sizes of screens, what constraints do we add?

Look at these constraints in the picture, will you feel the inexplicable irritability, at least I am. Even more maddening is that if you need to add a rectangle in the middle, then you have to modify the association of several constraints, there is no push-table impulse?

However, our developers are always fortunate that Apple has added a new feature StackView in Xcode7, which is a perfect solution to this disturbing problem.

StackView is actually a view container, but it will automatically lay out its child views according to certain rules, layout the sub-views as a stack, and have several main properties:

direction

The StackView has a layout pattern in horizontal and vertical two directions:

interval

StackView can set the interval between child views:

Alignment

StackView You can set the alignment of a child view (which differs horizontally and vertically in the property value):

    • Fill: Child view fills StackView.
    • Leading: Align Left.
    • Trailing: Align Right.
    • Center: The child View is aligned as a centerline.
    • Top: Align on top.
    • Bottom: Align to bottom.
    • First Baseline: Aligns with the line of text in the first child view.
    • Last Baseline: Aligns with the final line of text in the last child view.
Distribution ratio

StackView you can set the distribution scale of the sub-view:

    • Fill: The default distribution mode.
    • Fill equally: the height or width of the child view remains the same.
    • Fill:Proportionally:StackView himself calculates the distribution that it deems appropriate.
    • Equal Spacing: Sub-views are distributed in equal intervals.
    • Equal centering: Maintains a consistent distribution between each child view centerline.

All let the example speak, in this article we will gradually develop a film critic application to explain in detail how to use StackView.

likes aCollection

IOS 9 Interface Adaptation: A new feature of Xcode 7 Uistackview

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.