Any Modifier
available to stop bounce of ScrollView
in swiftUI
?
struct RoomDetailsView: View {
var body: some View {
ScrollView(showsIndicators: false) {
Image("test")
Text("Hello Text")
...
...
}
}
}
I tried below code but it not work for me. looks like it deprecated
ScrollView(alwaysBounceVertical: true) {
Image("test")
Text("Hello Text")
...
...
}
The Answers struct RoomDetailsView: View { init() { UIScrollView. appearance(). bounces = false } var body: some View { ScrollView(showsIndicators: false) { Image("test") Text("Hello Text") ... ... } } }
Figure 1. The ScrollView of SwiftUI allows efficient creation of scrolling containers. The view automatically adjust its size to fit the placed objects inside. It will also place some adjustments in order to avoid safe areas. ScrollView can be scrolled horizontally, vertically, or both.
try using this line of code:
UIScrollView.appearance().bounces = false
You can use it like this:-
struct RoomDetailsView: View {
init() {
UIScrollView.appearance().bounces = false
}
var body: some View {
ScrollView(showsIndicators: false) {
Image("test")
Text("Hello Text")
...
...
}
}
}
Or you can write this line in AppDelegate to apply this behaviour throughout into your app.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIScrollView.appearance().bounces = false
}
You may use SwiftUI-Introspect library:
ScrollView {
// some content
}
.introspectScrollView { scrollView in
scrollView.alwaysBounceVertical = false
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With