Revert "remove unnecessary guard statement"

This reverts commit 272162ddb7.
This commit is contained in:
zhongwuzw
2017-11-06 15:00:20 +08:00
parent 272162ddb7
commit 71b60faf4a
+6
View File
@@ -443,6 +443,8 @@ open class MessageInputBar: UIView {
/// - Parameter positions: The UIStackView's to layout
public func layoutStackViews(_ positions: [InputStackView.Position] = [.left, .right, .bottom, .top]) {
guard superview != nil else { return }
for position in positions {
switch position {
case .left:
@@ -507,6 +509,7 @@ open class MessageInputBar: UIView {
$0.parentStackViewPosition = position
leftStackView.addArrangedSubview($0)
}
guard superview != nil else { return }
leftStackView.layoutIfNeeded()
case .right:
rightStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
@@ -516,6 +519,7 @@ open class MessageInputBar: UIView {
$0.parentStackViewPosition = position
rightStackView.addArrangedSubview($0)
}
guard superview != nil else { return }
rightStackView.layoutIfNeeded()
case .bottom:
bottomStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
@@ -525,6 +529,7 @@ open class MessageInputBar: UIView {
$0.parentStackViewPosition = position
bottomStackView.addArrangedSubview($0)
}
guard superview != nil else { return }
bottomStackView.layoutIfNeeded()
case .top:
topStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
@@ -534,6 +539,7 @@ open class MessageInputBar: UIView {
$0.parentStackViewPosition = position
topStackView.addArrangedSubview($0)
}
guard superview != nil else { return }
topStackView.layoutIfNeeded()
}
}