on-internet
← Community

How to size a view relative to its parent when the parent is inside a scrollview?

Stack Overflow ·

I'm trying to dynamically size some views which end up being placed inside of a scrollview. Here is the simplest sample code I can think of: struct RootView: View { var body: some View { ScrollView { VStack(alignment: .leading) { // More views above HStack(spacing: 16) { MyView() MyView() } .padding([.leading, .trailing], 16) // More views below } } } } struct MyView: View { var body: some View { VStack(alignment: .leading, spacing: 24) { Image("myImage") .resizable() .scaledToFill() VStack(alignment: .leading, spacing: 0) { Text("Text") OtherView() } } } } I think really the main issue I'm ha

Comments

Sign in or sign up to comment and upvote.

No comments yet.