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.

x-ray correct area circled.

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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -