Post

Replies

Boosts

Views

Activity

Is UIViewRepresentable even capable of handling autolayout within a view?
I have a UIView component that has a series of views within it: some UILabels, a UITextField, a couple UIImageViews, etc. All of it is held together with autolayout to work. It will stretch to whatever space I specify horizontally, but it very strictly handles the vertical space based on need. Here's what it should look like. Now, I want to create a UIViewRepresentable so that I can use this component in a SwiftUI project. What I am finding is that I simply cannot find a way to have this component laid out correctly in SwiftUI. If I use.fixedSize(horizontal: false, vertical: true)the view disappears because no vertical space is allocated at all. If I use.frame(width: 375.0, height: 100.0)it will appear as expected but hardcoding the size is not possible for my needs. Same problem if I supply anintrinsicContentSizeI can't know the height in advance.Is there *any* way for SwiftUI to use a UIViewRepresentable to wrap this component and let autolayout dictate its size? How is this not possible?I put together a barebones project that demonstrates the problem here as concisely as possible: https://www.dropbox.com/s/e5zqlmaqoosbv33/RepresentableSizing.zip?dl=0
2
3
6.3k
Apr ’20