@@ -22,6 +22,14 @@ import Foundation
2222#if os(iOS) || os(tvOS)
2323import UIKit
2424
25+ extension UIView {
26+ fileprivate struct pinlayoutAssociatedKeys {
27+ static var pinlayoutIsIncludedInPinLayout = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
28+ static var pinlayoutAutoSizingRect = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
29+ static var pinlayoutAutoSizingRectWithMargins = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
30+ }
31+ }
32+
2533extension UIView : Layoutable , SizeCalculable {
2634 public typealias PinView = UIView
2735
@@ -37,6 +45,15 @@ extension UIView: Layoutable, SizeCalculable {
3745 return PinLayoutObjCImpl ( view: self , keepTransform: true )
3846 }
3947
48+ public var isIncludedInPinLayout : Bool {
49+ get {
50+ return objc_getAssociatedObject ( self , & pinlayoutAssociatedKeys. pinlayoutIsIncludedInPinLayout) as? Bool ?? true
51+ }
52+ set {
53+ objc_setAssociatedObject ( self , & pinlayoutAssociatedKeys. pinlayoutIsIncludedInPinLayout, newValue, objc_AssociationPolicy. OBJC_ASSOCIATION_RETAIN_NONATOMIC)
54+ }
55+ }
56+
4057 public func getRect( keepTransform: Bool ) -> CGRect {
4158 guard !Pin. autoSizingInProgress || autoSizingRect == nil else { return autoSizingRect ?? CGRect . zero }
4259
@@ -94,11 +111,6 @@ extension UIView: Layoutable, SizeCalculable {
94111}
95112
96113extension UIView : AutoSizeCalculable {
97- private struct pinlayoutAssociatedKeys {
98- static var pinlayoutAutoSizingRect = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
99- static var pinlayoutAutoSizingRectWithMargins = UnsafeMutablePointer< Int8> . allocate( capacity: 1 )
100- }
101-
102114 private var autoSizingRect : CGRect ? {
103115 get {
104116 return objc_getAssociatedObject ( self , & pinlayoutAssociatedKeys. pinlayoutAutoSizingRect) as? CGRect
0 commit comments