I want to be able to drag down on the scroll view and the large navigation title must not stick to the content as it is hiding a view when scrolling down.
The way I was able to fix this behaviour is to add a fake view to the hierarchy so that the scrollview is not the base view of the screen, as it seems if the scrollview is the base view it automatically adds this sticky behaviour. Just adding a plain VStack or EmptyView does not seem to work either as its able to tell that the scrollview is somehow still the base view.
VStack {
// Stops large navigation titles from sticking to the scrollview if the scroll view is the base view
FakeView().fixedSize()
// Your previous root scrollview
ScrollView {
}
}
struct FakeView: UIViewRepresentable {
public func makeUIView(context: UIViewRepresentableContext<Self>) -> UIView {
UIView()
}
public func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<Self>) {
}
}
3
Answers
The way I was able to fix this behaviour is to add a fake view to the hierarchy so that the scrollview is not the base view of the screen, as it seems if the scrollview is the base view it automatically adds this sticky behaviour. Just adding a plain
VStack
orEmptyView
does not seem to work either as its able to tell that the scrollview is somehow still the base view.It should work w/o representable, like
You can add a view to fill the screen such as a
Color
, and the apply yourScrollView
as an overlay