-1

I am drawing a line using UIBezierPath

[path moveToPoint:CGPointMake(xco2, yco2)];
[path addLineToPoint:CGPointMake(xco, yco)];

CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [[UIColor whiteColor] CGColor];
shapeLayer.lineWidth = 3.0;
shapeLayer.fillColor = [[UIColor clearColor] CGColor];

[self.view.layer addSublayer:shapeLayer];

this is the code snippet by which I am drawing lines , but using this code I can only able to draw solid lines , but my client need many customized line like dotted lines , dashed lines etc and other customized lines . I am new in Xcode and I need help to do this

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ron
  • 394
  • 1
  • 12
  • 24

1 Answers1

2

You can use following method's to change line pattern

[shapeLayer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:10],
 [NSNumber numberWithInt:5],nil]];
 shapelayer.lineJoin = kCALineJoinMiter;
 shapelayer.lineDashPhase = 3.0f;
  • Thanks @rmrahul it works . Also if I need a line which lookes like arrow in both side like "<-----------> " this. – Ron Jan 02 '14 at 10:09
  • You have to draw ">" programatically. check this for idea http://stackoverflow.com/questions/13528898/how-can-i-draw-an-arrow-using-core-graphics –  Jan 02 '14 at 10:48