diff --git a/Sources/UseAutoLayout/UseAutoLayout.swift b/Sources/UseAutoLayout/UseAutoLayout.swift index 87a8d74..2fcec70 100644 --- a/Sources/UseAutoLayout/UseAutoLayout.swift +++ b/Sources/UseAutoLayout/UseAutoLayout.swift @@ -3,15 +3,19 @@ import UIKit @propertyWrapper public struct UseAutoLayout { - var value: T - public var wrappedValue: T { - get { return value } - set { self.value.translatesAutoresizingMaskIntoConstraints = false } + didSet { + setAutoLayout() + } } public init(wrappedValue: T) { - value = wrappedValue + self.wrappedValue = wrappedValue + setAutoLayout() + } + + func setAutoLayout() { + wrappedValue.translatesAutoresizingMaskIntoConstraints = false } } #endif