ios - How to set specific areas of uiimage to process touch gestures? -
i'm making photo hunt style app. i've got number of x-rays , need set specific areas of uiimage process touch events correct , others incorrect.
i understand can use code below tap location in image view how declare area on image view correct , compare tap location value?
cgpoint taplocation = [gesture locationinview:self.imageplatea];
any appreciated!
so have programmatically create "regions" , test see whether or not they're in region after point. example:
//get tap location cgpoint taplocation = [gesture locationinview:self.imageplatea]; if ([self checkiftap:taplocation inregionwithcenter:cgpointmake(somex, somey) radius:radius]) { //yay we're within bounds of circle @ point (somex, somey) //that has radius of radius }
and method of checkiftap: inregionwithcenter: radius: can defined this:
- (bool)checkiftap:(cgpoint)taplocation inregionwithcenter:(cgpoint)center radius:(cgfloat)radius { cgfloat dx = taplocation.x - center.x; cgfloat dy = taplocation.y - center.y; //pythagorean theorem if (sqrt(dx * dx + dy * dy) < radius) { return yes; } else { return no; } }
Comments
Post a Comment