Draw ellipse inside Rect iOS swift with layerWidth

 Solution:

Want to draw an eclipse with layer width but if i change the layerwidth object must be inside the rect.So used the below code to achieve that.

  CGContextRef ctx = UIGraphicsGetCurrentContext();

  CGContextClearRect(ctx, rect);

  CGContextSetLineWidth(ctx, self.Width);

  CGRect shapeRect;

  shapeRect = CGRectMake(00self.bounds.size.widthself.bounds.size.height);

  CGContextClearRect(ctx, rect);

  CGContextSetLineWidth(ctx, self.Width);

  CGPathRef path = CGPathCreateWithRect(shapeRect, NULL);

  CGContextRef context = UIGraphicsGetCurrentContext(); // not needed, but if you're doing other drawing, it'll be needed.  


    shapeRect = CGRectMake(shapeRect.origin.x+Width, shapeRect.origin.y+Width, shapeRect.size.width-(Width*2), shapeRect.size.height-(Width*2));

      CGContextSetStrokeColorWithColor(ctx, color.CGColor);

      [[UIColor clearColorsetFill];

      CGContextStrokeEllipseInRect(UIGraphicsGetCurrentContext(), shapeRect);

      break;


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift