how to use Stack View of object library in Xcode 7

南楼画角 提交于 2020-01-01 09:44:24

问题


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:


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



来源:https://stackoverflow.com/questions/30779724/how-to-use-stack-view-of-object-library-in-xcode-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!