ios9中 UIStackView的使用
by 伍雪穎
UIStackView可以
垂直或水平排布多個subview,
本身主動爲每個subview建立和加入Auto Layout constraints.
1.加入subview
let
logoImage:
UIImageView
=
UIImageView
(image:
UIImage
(named:
"logo"
))
logoImage.
contentMode
= .
ScaleAspectFit
self
.stackView.addArrangedSubview(logoImage)
UIView
.animateWithDuration(
0.25
, animations: {
self
.stackView.layoutIfNeeded()
})
2.刪除subview
self
.stackView.removeArrangedSubview(logoView)