Si quelqu'un a jamais ce problème, le code suivant permet de détection de bord extrêmement précis tout en faisant glisser. Si vous faites glisser le bouton, il ne dépassera pas le bord du bouton comme d'habitude.
(je UIButton et fait sous-classé les éléments suivants :)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
touchBlocker = TRUE;
self.highlighted = TRUE;
NSLog(@"Touch Began");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self];
if (touchBlocker) {
if (!CGRectContainsPoint([self bounds], location)) {
touchBlocker =FALSE;
self.highlighted = FALSE;
NSLog(@"Touch Exit");
}
} else if (CGRectContainsPoint([self bounds], location)) {
touchBlocker = TRUE;
self.highlighted = TRUE;
NSLog(@"Touch Enter");
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
touchBlocker = FALSE;
self.highlighted = FALSE;
NSLog(@"Touch Ended");
}