PQTabBar.swift 723 B

123456789101112131415161718192021222324252627
  1. //
  2. // PQTabBar.swift
  3. // PQSpeed
  4. //
  5. // Created by SanW on 2021/1/18.
  6. // Copyright © 2021 BytesFlow. All rights reserved.
  7. //
  8. import UIKit
  9. public class PQTabBar: UITabBar {
  10. override open func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
  11. if isHidden { // 如果隐藏的话不处理事件
  12. return super.hitTest(point, with: event)
  13. }
  14. let view = super.hitTest(point, with: event)
  15. if view == nil {
  16. for subView in subviews {
  17. let myPoint = subView.convert(point, from: self)
  18. if subView.bounds.contains(myPoint) {
  19. return subView
  20. }
  21. }
  22. }
  23. return view
  24. }
  25. }