Skip to content

Commit

Permalink
[FIX] hitTest iOS18 이슈 수정 (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimkyuchul committed Dec 1, 2024
1 parent 9da2a58 commit 457e911
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@
import SwiftUI

final class PassThroughWindow: UIWindow {
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard let hitView = super.hitTest(point, with: event) else { return nil }
return rootViewController?.view == hitView ? nil : hitView
}
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
guard let hitView = super.hitTest(point, with: event),
let rootView = rootViewController?.view
else {
return nil
}

if #available(iOS 18, *) {
for subview in rootView.subviews.reversed() {
let convertedPoint = subview.convert(point, from: rootView)
if subview.hitTest(convertedPoint, with: event) != nil {
return hitView
}
}
return nil
} else {
return hitView == rootView ? nil : hitView
}
}
}

0 comments on commit 457e911

Please sign in to comment.