I wanna disable multi touch in swiftUI but I don't find any solution Is there any way to do this???
everything I found are related to UIKit :
I wanna disable multi touch in swiftUI but I don't find any solution Is there any way to do this???
everything I found are related to UIKit :
No SwiftUI solution but you can use UIKit solution in SwiftUI app.
Use UIView.appearance()
. This will disable multi-touch on the whole app.
@main
struct SwiftUIDEMO: App {
init() {
UIView.appearance().isMultipleTouchEnabled = false
UIView.appearance().isExclusiveTouch = true
}
// Body View
}
Or you can also use UIViewController
touch event and maange .isUserInteractionEnabled
.
extension UIViewController {
open override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
self.view.isUserInteractionEnabled = true
}
open override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
self.view.isUserInteractionEnabled = true
}
open override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesEnded(touches, with: event)
self.view.isUserInteractionEnabled = true
}
}