我有一个包含 UIScrollView 的 ViewController,我试图仅在 View 顶部禁用弹跳效果。
我尝试添加 this answer在我的 ViewController 类中,它说要这样做:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
//disable bounce only at the top of the screen
scrollView.bounces = scrollView.contentOffset.y > 100
}
但是我真的不知道该怎么办。我还尝试实现 UIScrollViewDelegate。
我试过都没用。
Here is my StoryBoard and ViewController
我需要做什么才能让它发挥作用?
我的设置:
- Swift 版本:5.1.3
- Xcode 版本:11.3.1
- 目标 iOS 版本:13.2
- MacBook Pro(13 英寸,2016 年,四个 Thunderbolt 3 端口)MacOS Catalina 10.15.2 (19C57)
最佳答案
连接 scrollView socket 然后尝试添加 scrollView.delegate = self
或添加 scrollView.bounces = scrollView.contentOffset.y > 100
在你的 viewDidLoad()
函数。
关于ios - UIScrollView 禁用顶部弹跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59965977/