@@ -29,13 +29,6 @@ public protocol Layoutable: AnyObject, Equatable, CustomDebugStringConvertible {
2929 var superview : PinView ? { get }
3030 var subviews : [ PinView ] { get }
3131
32- /// A Boolean value that determines whether the view is included in the PinLayout's size calculation.
33- ///
34- /// An excluded view does not take up space in the layout
35- /// when using `wrapContent(_:padding:_:)` or `autoSizeThatFits(_:layoutClosure:)`.
36- /// The default value is `true`.
37- var isIncludedInPinLayoutSizeCalculation : Bool { get set }
38-
3932 func getRect( keepTransform: Bool ) -> CGRect
4033 func setRect( _ rect: CGRect , keepTransform: Bool )
4134
@@ -44,8 +37,22 @@ public protocol Layoutable: AnyObject, Equatable, CustomDebugStringConvertible {
4437 func isLTR( ) -> Bool
4538}
4639
40+ private struct pinlayoutAssociatedKeys {
41+ static var pinlayoutIsIncludedInSizeCalculation = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
42+ }
43+
4744extension Layoutable {
45+
46+ var isIncludedInSizeCalculation : Bool {
47+ get {
48+ return objc_getAssociatedObject ( self , & pinlayoutAssociatedKeys. pinlayoutIsIncludedInSizeCalculation) as? Bool ?? true
49+ }
50+ set {
51+ objc_setAssociatedObject ( self , & pinlayoutAssociatedKeys. pinlayoutIsIncludedInSizeCalculation, newValue, objc_AssociationPolicy. OBJC_ASSOCIATION_RETAIN_NONATOMIC)
52+ }
53+ }
54+
4855 var subviewsIncludedInSizeCalculation : [ PinView ] {
49- return subviews. filter ( \. isIncludedInPinLayoutSizeCalculation )
56+ return subviews. filter ( \. isIncludedInSizeCalculation )
5057 }
5158}
0 commit comments