-
Notifications
You must be signed in to change notification settings - Fork 618
/
UIStackView+Layout.swift
executable file
·53 lines (48 loc) · 1.69 KB
/
UIStackView+Layout.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright © 2017 Schibsted. All rights reserved.
import UIKit
extension UIStackView {
override open class var expressionTypes: [String: RuntimeType] {
var types = super.expressionTypes
types["axis"] = .uiLayoutConstraintAxis
types["distribution"] = .uiStackViewDistribution
types["alignment"] = .uiStackViewAlignment
types["spacing"] = .cgFloat
types["arrangedSubviews"] = .unavailable()
// UIStackView is a non-drawing view, so none of these properties are available
for name in [
"backgroundColor",
"contentMode",
"layer.backgroundColor",
"layer.cornerRadius",
"layer.borderColor",
"layer.borderWidth",
"layer.contents",
"layer.masksToBounds",
"layer.shadowColor",
"layer.shadowOffset",
"layer.shadowOffset.height",
"layer.shadowOffset.width",
"layer.shadowOpacity",
"layer.shadowPath",
"layer.shadowPathIsBounds",
"layer.shadowRadius",
] {
types[name] = .unavailable()
}
return types
}
override open func didInsertChildNode(_ node: LayoutNode, at index: Int) {
super.didInsertChildNode(node, at: index)
addArrangedSubview(node.view)
}
override open func willRemoveChildNode(_ node: LayoutNode, at index: Int) {
(node._view as UIView?).map(removeArrangedSubview)
super.willRemoveChildNode(node, at: index)
}
override open class var defaultExpressions: [String: String] {
return [
"width": "auto",
"height": "auto",
]
}
}