Create Line in iOS Objective C

Solution:

In iOS you can create a Line using CGContextref.The below code is used for draw a line in a view in x1,y1, is 0,0 and x2,y2 is 20,20.



   CGContextRef ctx = UIGraphicsGetCurrentContext();
  CGRect rect = CGRectMake(00,20,20);
  CGContextClearRect(ctx, rect);
  CGContextSetStrokeColorWithColor(ctx, color.CGColor);
   CGContextSetLineCap(ctx, kCGLineCapRound);
   CGContextSetLineWidth(ctx, 10);
   CGContextSetAlpha(ctx, 1);
   CGContextMoveToPoint(ctx, 0, 0);
   CGContextAddLineToPoint(ctx, 20, 20);
   CGContextStrokePath(ctx);
   CGContextDrawPath(ctx, kCGPathFillStroke);

Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

store cgpoint in userdefaults iOS swift