Checking if a touch is within a UIButton’s bounds.
Checking if a touch is within a UIButton’s bounds.
- Subject: Checking if a touch is within a UIButton’s bounds.
- From: Joshua Garnham <email@hidden>
- Date: Sun, 18 Apr 2010 15:02:10 +0000 (GMT)
I am trying to make an if statement which will check whether the users touch is within a
UIButton's bounds. I thought this would be an easy affair as UIButton
is a subclass of UIView, however my code doesn't seem to work.
This is the code I have been using.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *array = [touches allObjects];
UITouch *specificTouch = [array objectAtIndex:0];
currentTouch = [specificTouch locationInView:self.view];
if (CGRectContainsPoint(button.bounds, currentTouch)) {
//Do something.
}
//Else do nothing.
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden