I did this with a special gesture. When the gesture sets the state of the gestures (from the start, move, or end of the touch), the gesture action callback returns back to the view and the view calls "setNeedsDisplayInRect" and then the drawing comes from drawRect .
The catch with your implementation is that you cannot set the graphical context from gesture tracking methods. If the view indicates that you need to redraw (via "setNeedsDisplay"), this is done for you.
The reason for this is that the contents of the view can be cached in the layer, which is very important for optimizing the animation and layout. Therefore, if you need to draw a view, keep the rest of the interface in sync with your changes by calling setNeedsDisplay and executing the drawing from your drawRect method.
source share