Reputation: 1
I have a subview over my view and i want this subview only to recognize pencil touch types. Every time the touch type is a finger i want it to be recognized by the parent view. Currently i am using the function shown below. The problem here is that the UIEvent has no touches so its not possible to check if it is a finger or pencil touch.
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return false
}
Upvotes: 0
Views: 578
Reputation: 3597
One option would be disabling user interaction on the bottom view, and in the top view implementing:
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent)
func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent)
func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent)
In these functions, you can check the type with touches.first?.type
, and you can check the view with touches.first?.view
, and if they satisfy your criteria you can call touchesBegan/Moved/Ended
on the bottom view.
Use these three methods:
func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent)
func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent)
func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent)
You can check they type with touches.first?.type, and you can check the view with touches.first?.view.
You could forward the touches by calling touchesBegan/Moved/Ended
on the view underneath.
Upvotes: 2