how to use Stack View of object library in Xcode 7

6.7k views Asked by At

I recently installed Xcode 7 beta and found something new in object library like

Horizontal stack view and Vertical stack view.

When i put some controls inside it, stackview seems to be resizable according to the control size. When i present more controls the stack seems to be adjust automatically as of the stack view. Either adjusting horizontally or vertically?

Is it derived from some other mobile platform

1

There are 1 answers

0
LC 웃 On BEST ANSWER

A major advantage of using UIStackView is it uses Auto Layout to position and size its arranged UIViews. Therefore you dont need to worry about positioning UIViews in a UIStackView.For a horizontal stack, this means the first arranged view’s leading edge is pinned to the stack’s leading edge, and the last arranged view’s trailing edge is pinned to the stack’s trailing edge. You can try by inserting two or more controls to a horizontal stack view,how they align horizontally w.r.t each other.

The UIStackView class provides a streamlined interface for laying out a collection of views in either a column or a row. Stack views let you leverage the power of Auto Layout, creating user interfaces that can dynamically adapt to the device’s orientation, screen size, and any changes in the available space. The stack view manages the layout of all the views in its arrangedSubviews property. These views are arranged along the stack view’s axis, based on their order in the arrangedSubviews array. The exact layout varies depending on the stack view’s axis, distribution, alignment, spacing, and other properties.

For how to use

Here is a detail tutorial from raywenderlich site:

http://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views

For More,Please have a look at https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/index.html