UIStackView

2018-01-19  本文已影响20人  AT19

1.UIStackView: 管理子视图,自动适配。@available(iOS 9.0, *)

/* A stack with a horizontal axis is a row of arrangedSubviews,
and a stack with a vertical axis is a column of arrangedSubviews.
 */
open var axis: UILayoutConstraintAxis


/* The layout of the arrangedSubviews along the axis
枚举值
case fill
case fillEqually
case fillProportionally
case equalSpacing
case equalCentering
 */
open var distribution: UIStackViewDistribution


/* The layout of the arrangedSubviews transverse to the axis;
 e.g., leading/trailing edges in a vertical stack
 */
open var alignment: UIStackViewAlignment


/* Spacing between adjacent edges of arrangedSubviews.
 Used as a strict spacing for the Fill distributions, and
 as a minimum spacing for the EqualCentering and EqualSpacing
 distributions. Use negative values to allow overlap.
 
 On iOS 11.0 or later, use UIStackViewSpacingUseSystem (Swift: UIStackView.spacingUseSystem) 
 to get a system standard spacing value. Setting spacing to UIStackViewSpacingUseDefault 
 (Swift: UIStackView.spacingUseDefault) will result in a spacing of 0.
 
 System spacing between views depends on the views involved, and may vary across the 
 stack view.
 
 In vertical stack views with baselineRelativeArrangement == YES, the spacing between 
 text-containing views (such as UILabels) will depend on the fonts involved.
 */
open var spacing: CGFloat

2.添加方式:
1.>UIStoryBoard方式添加: 简单添加子视图适配即可

xib 添加方式
2.>代码添加方式:(摘自网路上的)
点击这里

3.运行app
1.> 横屏时

横屏
2.>竖屏时
竖屏
上一篇 下一篇

猜你喜欢

热点阅读