SwiftUI ScrollView is not able to disable vertical bounce?

微笑、不失礼 提交于 2020-05-29 03:53:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!