Like others, you should have a reasonable surface for recording touch events, but I'm sure you know this and have your own reasons, so I'll just tell you how I did it:
I needed to do this not so long ago, and I did what Sixten Otto suggested. In my original question (UPDATE section) there are some tips for getting the alpha value for your image at a specific point:
?
: UIControl , - , "", UIButton PNG . , UIControl " ".
, UIControl , - , alpha == 0. drawRect: NSImage drawInRect:fromRec:operation:fraction:, .
:
buttonImage = [NSImage imageNamed:@"myButtonImage"];
buttonImageRep = [[buttonImage representations] objectAtIndex:0];
: ( stateImage , , )
- (void)drawRect:(NSRect)aRect {
[stateImage drawInRect:[self bounds] fromRect:NSMakeRect(0.0,0.0,[buttonImage size].width,[buttonImage size].height)
operation:NSCompositeSourceOver fraction:1.0];
}
png-. , 0:
NSColor *colorUnderMouse = [buttonImageRep colorAtX:mouse.x y:mouse.y];
float alpha = [colorUnderMouse alphaComponent];
, , . , !
N.B: Mac, iPhone, , .