you can check the pixel color of the rbga image and see if there is a value (= alpha) == 0 (or <= aLowValue) ... as suggested by Igor Pchelko ...
but in your case it could be simpler ... you are using a two-dimensional circle, so just check how your finger click is far from the center of the circle and see if it has its radius ... just an application of the Pythagorean theorem ...
EDIT:
ok, so if you create a new class to subclass the UIButton button:
in YourButton.h:
#import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @interface YourButton : UIButton { } @end
in YourButton.m just add this code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; CGPoint touchPoint = [touch locationInView:self]; NSLog(@"Touch x : %fy : %f", touchPoint.x, touchPoint.y); float circleRadius = self.frame.size.height / 2;
source share