BackgroundView.swift 744 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // BackgroundView.swift
  3. // Pods
  4. //
  5. // Created by Daniel Lozano Valdés on 3/20/17.
  6. //
  7. //
  8. import UIKit
  9. class PassthroughBackgroundView: UIView {
  10. var passthroughViews: [UIView] = []
  11. var shouldPassthrough = true
  12. override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
  13. var view = super.hitTest(point, with: event)
  14. if !shouldPassthrough {
  15. return view
  16. }
  17. if view == self {
  18. for passthroughView in passthroughViews {
  19. view = passthroughView.hitTest(convert(point, to: passthroughView), with: event)
  20. if view != nil {
  21. break
  22. }
  23. }
  24. }
  25. return view
  26. }
  27. }