Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight the button when drag enter

Tags:

ios

uibutton

just started to explore iOS SDK. I have some buttons, need to highlight them touching outside once and then drag. As I understand, TouchDragEnter event fires when you click the button then drag outside then drag inside again. Is there any event fires when you click outside the button and then drag inside?

like image 420
Alexander B Avatar asked Oct 29 '11 10:10

Alexander B


1 Answers

Alexander,

Searching for the same info, I saw your question hadn't been answered. You've probably already figured it out, but here's how I've done it.

Note that the pointInside:withEvent: method checks to see if the point lies within the button's bounds. Since the touch event is coming from the view, you have to convert it to the button's coordinate system.

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *t in touches) {
    CGPoint touchPoint = [t locationInView:self.view];

    CGPoint testPoint = [self.view convertPoint:touchPoint toView:aButton];
    if ([aButton pointInside:testPoint withEvent:event]) {
        //Do something
    }
    //rest of code
like image 51
Chris C Avatar answered Sep 29 '22 05:09

Chris C