I was wondering how to draw a circle around a point taken from a control's positioning.
This is not working as hoped
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(contextRef, 2.0);
CGContextSetRGBFillColor(contextRef, 0, 0, 1.0, 1.0);
CGContextSetRGBStrokeColor(contextRef, 0, 0, 1.0, 1.0);
CGRect circlePoint = (CGRectMake(self.frame.size.width / 2, self.frame.size.height / 2, 10.0, 10.0));
CGContextFillEllipseInRect(contextRef, circlePoint);
I think its pretty easy to draw a circle using UIBezierPath. All you need to do is subclass UIView and create UIBezierPath. I have created a example using UIBezierPath :
Create a subclass of UIView called CirecleView. Add following code :
Change your controller's view class to CircleView. Please see below picture.
Thats it. Run your code to present your controller's view. Following is the output :
You can down code example from here
You just need to translate to the point first
Note this is Swift 3, it may be different in other languages, just search "translate cgcontext"