How to disable ScrollView Bounce In SwiftUI

前端 未结 1 1582
情深已故
情深已故 2021-01-18 08:51

Any Modifier available to stop bounce of ScrollView in swiftUI ?

struct RoomDetailsView: View {

    var body: some Vi         


        
相关标签:
1条回答
  • 2021-01-18 09:35

    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
     }
    
    0 讨论(0)
提交回复
热议问题