Skip to content

Instantly share code, notes, and snippets.

@Josscii
Created May 3, 2020 07:40
Show Gist options
  • Save Josscii/41744b0741c1daa80429ea05c413d68c to your computer and use it in GitHub Desktop.
Save Josscii/41744b0741c1daa80429ea05c413d68c to your computer and use it in GitHub Desktop.
修复在 scrollView 中的 UIControl 及其子类的点击问题
import UIKit
class FixControlTouchScrollView: UIScrollView {
override init(frame: CGRect) {
super.init(frame: frame)
delaysContentTouches = false
}
required init?(coder: NSCoder) {
super.init(coder: coder)
delaysContentTouches = false
}
override func touchesShouldCancel(in view: UIView) -> Bool {
if view.isKind(of: UIControl.self) {
return true
}
return super.touchesShouldCancel(in: view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment