Some remarks :
Instead of overriding UIView touch event methods, you should use a
UIGestureRecognizer
. In your case, aUItapGestureRecognizer
might be enough. (this way, it will be easier to handle conflict between different touch actions, that's the reason why gestureRecognizers were created!)When you receive tap, change a local property of your view (for example, a BOOL
isRectangleDrawn
might be changed each time the view receives the tap)Finally - and that's what missing in your code, that otherwise should be correct - don't forget to call
[self setNeedsDisplay]
to be sure your view's- (void) drawRect:(CGRect)rect
method gets called