如何在 Xcode 7 中使用对象库的堆栈视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30779724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to use Stack View of object library in Xcode 7
提问by ak2g
I recently installed Xcode 7 betaand found something newin object library like
我最近安装了Xcode 7 beta并在对象库中发现了一些新的东西 ,比如
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?
当我在其中放置一些控件时,stackview 似乎可以根据控件大小调整大小。当我呈现更多控件时,堆栈似乎在堆栈视图中自动调整。是水平调整还是垂直调整?
Is it derived from some other mobile platform
是否源自其他移动平台
采纳答案by Anish Parajuli ?
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.
使用的一个主要优点UIStackView
是它使用自动布局来定位和调整其排列的UIViews
. 因此,您无需担心在UIStackView
. 中定位 UIViews 。对于水平堆栈,这意味着第一个排列的视图的前缘固定到堆栈的前缘,最后一个排列的视图的后缘固定到堆栈的后缘。您可以尝试将两个或多个控件插入到水平堆栈视图中,以了解它们如何相互水平对齐。
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.
UIStackView 类提供了一个简化的界面,用于在列或行中布置视图集合。堆栈视图让您可以利用自动布局的强大功能,创建可以动态适应设备方向、屏幕大小和可用空间的任何变化的用户界面。堆栈视图在其排列的子视图属性中管理所有视图的布局。这些视图沿堆栈视图的轴排列,基于它们在排列的子视图数组中的顺序。确切的布局取决于堆栈视图的轴、分布、对齐方式、间距和其他属性。
For how to use
关于如何使用
Here is a detail tutorial from raywenderlich site:
这是来自 raywenderlich 站点的详细教程:
http://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
http://www.raywenderlich.com/114552/uistackview-tutorial-introducing-stack-views
For More,Please have a look athttps://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/index.html