File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ public struct UIViewContainer<Child: UIView>: Identifiable {
6363 public init ( _ view: @autoclosure ( ) -> Child , layout: Layout = . intrinsic) {
6464 self . view = view ( )
6565 self . layout = layout
66+
67+ switch layout {
68+ case . intrinsic:
69+ return
70+ case . fixed( let size) :
71+ self . view. widthAnchor. constraint ( equalToConstant: size. width) . isActive = true
72+ self . view. heightAnchor. constraint ( equalToConstant: size. height) . isActive = true
73+ case . fixedWidth( let width) :
74+ self . view. widthAnchor. constraint ( equalToConstant: width) . isActive = true
75+ }
6676 }
6777
6878 /// Applies the correct size to the SwiftUI `View` container.
@@ -87,8 +97,6 @@ public struct UIViewContainer<Child: UIView>: Identifiable {
8797extension UIViewContainer : UIViewRepresentable {
8898
8999 public func makeUIView( context: Context ) -> UIView {
90- view. widthAnchor. constraint ( equalToConstant: size. width) . isActive = true
91- view. heightAnchor. constraint ( equalToConstant: size. height) . isActive = true
92100 return view
93101 }
94102
You can’t perform that action at this time.
0 commit comments