iOS9新特性之UIStackView

UIStackView属性介绍
@property(nonatomic) UILayoutConstraintAxis axis;//排列方式
typedefNS_ENUM(NSInteger, UILayoutConstraintAxis) {
    UILayoutConstraintAxisHorizontal = 0,//水平方向排列
    UILayoutConstraintAxisVertical = 1   //竖直方向排列
};
@property(nonatomic) CGFloat spacing;//改变UIView间距
@property(nonatomic) UIStackViewAlignment alignment;//对齐方式
typedefNS_ENUM(NSInteger, UIStackViewAlignment) {
/* Align the leading and trailing edges of vertically stacked items
or the top and bottom edges of horizontally stacked items tightly to the container.
*/
UIStackViewAlignmentFill,

/* Align the leading edges of vertically stacked items
or the top edges of horizontally stacked items tightly to the relevant edge
of the container
*/
UIStackViewAlignmentLeading,
UIStackViewAlignmentTop = UIStackViewAlignmentLeading,
UIStackViewAlignmentFirstBaseline, // Valid for horizontal axis only

/* Center the items in a vertical stack horizontally
or the items in a horizontal stack vertically
*/
UIStackViewAlignmentCenter,

/* Align the trailing edges of vertically stacked items
or the bottom edges of horizontally stacked items tightly to the relevant
edge of the container
*/
UIStackViewAlignmentTrailing,
UIStackViewAlignmentBottom = UIStackViewAlignmentTrailing,
UIStackViewAlignmentLastBaseline, // Valid for horizontal axis only

} NS_ENUM_AVAILABLE_IOS(9_0);
1.垂直对齐的改不了宽度的原因
就是UIStackView的对齐属性是fill,每个UIview会填充整个界面,我们可以改成其它的对齐方式就可以改变了。
@property(nonatomic) UIStackViewDistribution distribution;//一些宽高的设置是否相等
分享到: 更多
Separator image Posted in IOS.

发表评论

电子邮件地址不会被公开。 必填项已用*标注