Created
February 6, 2020 13:17
-
-
Save Thomvis/cf4d492ee7352d64825bc3d5767d15d2 to your computer and use it in GitHub Desktop.
It seems that `onPreferenceChange` is not always called. I have an override using `overlayPreferenceValue` and `View.id`. I suspect the fact this view is inside a `ScrollView` matters.
This file contains hidden or 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
content | |
.onPreferenceChange(SizeKey.self, perform: { sizes in | |
// this is not always called | |
}) | |
.overlayPreferenceValue(SizeKey.self) { sizes in | |
EmptyView().onAppear { | |
// this is called more reliably | |
// the view's id controls for which changes this is called | |
}.id(sizes.map { $0.width*1000+$0.height }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment