Skip to content

Commit f221d1e

Browse files
committed
- remove unnecessary value
- autolayout code moved to `setAutoLayout` function
1 parent c2b82f1 commit f221d1e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

Sources/UseAutoLayout/UseAutoLayout.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import UIKit
33

44
@propertyWrapper
55
public struct UseAutoLayout<T: UIView> {
6-
var value: T
7-
86
public var wrappedValue: T {
9-
get { return value }
10-
set { self.value.translatesAutoresizingMaskIntoConstraints = false }
7+
didSet {
8+
setAutoLayout()
9+
}
1110
}
1211

1312
public init(wrappedValue: T) {
14-
value = wrappedValue
13+
self.wrappedValue = wrappedValue
14+
setAutoLayout()
15+
}
16+
17+
func setAutoLayout() {
18+
wrappedValue.translatesAutoresizingMaskIntoConstraints = false
1519
}
1620
}
1721
#endif

0 commit comments

Comments
 (0)