ios - Draw circle around custom UIBezierPath -


I have a UIBezierPath that has been dragged by the user on the touchscreen. Now I want to make a cycle around this path / drawing, and the path should be in the middle of this circle. I tried to use:

  UIBezierPath.bounds   

But obviously it does not work :( So my next idea is to point out every point in UIBezierPath Go through the medium and get the "lowest" point and the most "left" point, then attract the circle based on those points.

My question is, to pull a circle around Is there a more beautiful and efficient way for custom UIBezierPath?

From:

  NSMutableArray * bezierPoints = [NSMutableArray array]; CGPathApply (drawpath.CGPath, (__Bridge zero *), myCGPathApplierFunc) Float Minx = 100000.F; Float Minawy = 100000.f; (for the bezierPoints in the NSVL value) {CGPoint point = Value.CGPointValue; if (point xxlt; minX) minX = point.x; if (point.A  drawpath.bounds.size.he ight) {radius = drawpath.bounds.size.width * 0.65; } And {radius = drawpath.bounds.size.height * 0.65; } CGMutablePathRef myPath = CGPathCreateMutable (); CGPathAddArc (myPath, NULL, MIDX, MIDI, RADIUS, 0, M_PI * 2, YES); SKShapeNode * node = [[SKShapeNode alloc] init]; Node.path = myPath; Node Fill collar = zero; Node .strokecolor = SKColor.redColor; [Self compound: node]; Zero MyCGPathApplierFunc (Zero * info, const CGPathElement * element) {NSMutableArray * bezierPoints = (__Bridge NSMutableArray *) information; CGPoint * points = element- & gt; Points; CGPathElementType type = element-> type; Switch (type) {Case is the KCGT elementMovepointpoint: // has 1 point [Bezier Points Add Object: [NSVL value versexiPoint: Points [0]] ;; break; The case has 1 point in kCGPathElementAddLineToPoint: // [Bezier Points addObject: [NSValue valueWithCGPN: points [0]] ;; break; The case has 2 digits in kCGPathElementAddQuadCurveToPoint: // [bezierPoints addObject: [NSValue valueWithCGPoint: Issue [0]] ;; [BezierPoints addObject: [NSValue valueWithCGPoint: points [1]]]; break; The case has 3 digits in kCGPathElementAddCurveToPoint: // [Bezier Points addObject: [NSValue valueWithCGPN: points [0]] ;; [BezierPoints addObject: [NSValue valueWithCGPoint: points [1]]]; [BezierPoints addObject: [NSValue valueWithCGPoint: points [2]]]; break; There is no point break in case kCGPathElementCloseSubpath: //; }}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -