64324

How to disable ScrollView Bounce In SwiftUI

<h3>Question</h3>

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") ... ... }
<h3>Answer1:</h3>

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 }

来源:https://stackoverflow.com/questions/58799474/how-to-disable-scrollview-bounce-in-swiftui

Recommend

  • Can I test that a Sinatra post method successfully saves to a YAML store?
  • How to pass DataTable data to a Bootstrap modal
  • Python-demo(抖音)
  • Does HAL_GetTick() return ticks or milliseconds? (and how to measure in microseconds)
  • CSS style for container with transparent border images
  • Access to database zend framework
  • Videos won't upload
  • How to put an object in the air?
  • Auto send email based on the time and email address in database
  • Defer unused CSS
  • Sample deviceQuery cuda program
  • Android studio import problems. (Apktool)
  • What does “T extends Junk” mean in a generic class in Java?
  • Building JavaFX 2.0 App on Mac, deploying on Windows
  • Add checkbox dynamically using angular 2
  • How to load dynamic images in custom ListView
  • Delphi Prism getting Unknown Identifier “DllImport” error
  • What is the difference between dynamically creating a script tag and statically embed a script tag?
  • How do I use libcurl to printf a remote FTP directory listing?
  • Ajax call on Multiple selection in Select box
  • Creating 2d platforms using JavaScript
  • How to write seo friendly url's using htaccess?
  • Is there a better way for handling SpatialPolygons that cross the antimeridian (date line)?
  • r - input value by user to dataframe via shiny
  • How to clear a browser cache in Protractor
  • Cloud Code: Creating a Parse.File from URL
  • Terminal run dalvikvm with am.jar
  • How to handle div that is created dynamically in a table
  • Functions by reference or by variable, which to use when?
  • Make checkout phone field optional for specific countries in WooCommerce
  • Why my AngularJS async test in Jasmine 1.3.x is not working?
  • calling IO Operations from thread in ruby c extension will cause ruby to hang
  • Capture SIGFPE from SIMD instruction
  • Using Service Component Runtime
  • How to use FirstOrDefault inside Include
  • How do I use TagLib-Sharp to write custom (PRIV) ID3 frames?
  • WPF custom control and direct content support
  • CAS 4 - Not able to retrieve the LDAP groups after successful authentication
  • ReferenceError: TextEncoder is not defined
  • How to check if object is null in Java?