问题
There was a property in the initializer with ScrollView(alwaysBounceVertical: false) but I cant't seem to find it anymore.
Does anyone know how I can disable the vertical bounce / overscroll on a SwiftUI ScrollView?
回答1:
Yes, it has been removed from the initializer of ScrollView, now you have to update the appearance of the UIScrollView in order to restrict the scrolling.
UIScrollView.appearance().bounces = false
This line will restrict the scrolling, you can apply this in the AppDelegate(didFinishLaunching) or the init() method of your View.
回答2:
Yes, it changed in Beta 4:
ScrollView(.vertical, showsIndicators: false) { ... }
The new initializer is:
public init(_ axes: Axis.Set = .vertical, showIndicators: Bool = true, content: () -> Content)
来源:https://stackoverflow.com/questions/57132417/swiftui-scrollview-is-not-able-to-disable-vertical-bounce