Post

Replies

Boosts

Views

Activity

Reply to Is UIViewRepresentable even capable of handling autolayout within a view?
Question is old but for the benefit of others I had this problem with SwiftUI having no size for the UIViewRepresentable. I solved it by adding an intrinsicContentSize variable in the base view (not the UIViewRepresentable wrapper), that calculates the size based on the key subview frames and some padding. eg. swift override var intrinsicContentSize: CGSize { textContainer.frame.size + (mainViewPadding * 2) }
Mar ’21
Reply to GeometryReader Stops View Updating
I solved this eventually by adding another AnyView(...) to enclose all the view components inside the GeometryReader. I tried all sorts of things including using @ViewBuilder for the variable and with a function to return the view but the problem remained. Adding AnyView(...) to enclose the elements in the GeometryReader was the only way I found to make it work.   @Published var testValue: Double = 0   var resultView: AnyView {     AnyView (VStack{       Text("Text From Object, Outside of GeometryReader")       Text("Value \(self.testValue.description)")     GeometryReader {     geom in       AnyView( -> AnyView added to enclose code within GeometryReader       VStack{         VStack {         Text("Text From Object Inside Geom Reader")         Text(self.testValue.description).frame(width: geom.size.width / 2, height: geom.size.height / 3)         }.background(Color.secondary)         }       ) -> Close of AnyView added     } -> End of GeomReader }     )     } } // End of class
Jan ’21