kevj
kevj

Reputation: 87

How do you detect touches in specific UIView when sliding finger across mutiple UIViews

The scenario I am trying to solve is I have several UIViews as subviews of a master UIView. What I want to be able to do is highlight a views rect by lets say changing its border as a finger slides across the view..similar to what happens when you move/drag your mouse cursor over a hypertext link.

Upvotes: 1

Views: 2646

Answers (1)

highlycaffeinated
highlycaffeinated

Reputation: 19867

You can get the location of the touch inside your touchesMoved: method, then ask the master UIView which view was touched:

- (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event {
    UIView *subview = [masterView hitTest:[[touches anyObject] locationInView:masterView] withEvent:nil];
...
}

Upvotes: 4

Related Questions