Question

If i draw a circle using the CGContext ,is it possible to drag this circle using touch. Is there a way to check whether the touched area contains that drawn circle ?

I would like to create custom UIControl with either a circle or box shape.

Was it helpful?

Solution

What you can do is make the rect of that circle

CGRect myRect=CGRectMake(center.x-radius, cemter.y-radius, 2r, 2r);

and detect touch inside that rect by picking touch point as

CGPoint touch=[[touches anyObject]locationInView:self];
 if(CGRectContainsPoint(myRect,touch ))
{

//code here for true condition
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top