Last active
September 4, 2022 12:54
-
-
Save dmi-ch/dba914762af69e2c8e1a82f26635348e to your computer and use it in GitHub Desktop.
ScrollView shrink to fit content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@State private var scrollViewContentSize: CGSize = .zero | |
ScrollView { | |
VStack {} | |
.background( | |
GeometryReader { geo -> Color in | |
DispatchQueue.main.async { | |
scrollViewContentSize = geo.size | |
} | |
return Color.clear | |
} | |
) | |
}.frame( | |
maxHeight: scrollViewContentSize.height | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment