Don Wilson
Don Wilson

Reputation: 552

What is the best method to find the highest subview that contains a cgpoint?

Is there a faster method than looping through a uiview's subviews and testing cgrectcontainspoint?

Upvotes: 0

Views: 61

Answers (1)

zpasternack
zpasternack

Reputation: 17898

I haven't tried it myself, but it looks like hitTest:withEvent: will do what you want.

The doc says that it traverses the view hierarchy calling pointInside:withEvent on each subview, which probably ends up calling CGRectContainsPoint, so it's probably no faster. I'd probably still try it rather than looping through the subviews manually.

Upvotes: 1

Related Questions