cocoa touch - Have UITouch only perform task when touching certain color -


How can I identify UITouch and a specific task only when I can touch a certain color in a UIImage view I am

For example:

I have an image of the road, there are brown buildings in the street and a white road. If I touch a building, I should not do anything, but If I touch a white road, then I want to highlight that section where I touched a light blue color.

  • Use touch space to get pixel color at that location.
  • Decide whether the color represents the road or the building.
  • Get the exact touch coordinates

      - (zero) touch touch: Event with touch (NSSet *) :( UIEvent *) Event {UITouch * touch = [Touches anyObject]; CGPoint TouchPoint = [Touch Position Inview: Image View]; // Touch your touch coordinates here. Point.x Touchpoint Y}  

    Obtain pixel color at that place:

    Decide that the color represents the road.

      // 230 is used as an example, if used to find a good value (red> 230 & amp; & amp;; & green & gt; 230 And blue> 230) {// turn street blue}  

    Comments