arsena
arsena

Reputation: 1975

Change Dashed Line Thickness On IOS

I used this example to draw dashed line on uiview:

 UIBezierPath *path = [UIBezierPath bezierPath];
 //draw a line
 [path moveToPoint:yourStartPoint]; //add yourStartPoint here
 [path addLineToPoint:yourEndPoint];// add yourEndPoint here
 [path stroke];

 float dashPattern[] = {1,1,1,1}; //make your pattern here
 [path setLineDash:dashPattern count:4 phase:0];

 UIColor *fill = [UIColor blueColor];
 shapelayer.strokeStart = 0.0;
 shapelayer.strokeColor = fill.CGColor;
 shapelayer.lineWidth = 7.0;
 shapelayer.lineJoin = kCALineJoinMiter;
 shapelayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:10],[NSNumber numberWithInt:10], nil];
 shapelayer.lineDashPhase = 3.0f;
 shapelayer.path = path.CGPath;

it works, but problem is that even though I set my uiview height 1, the line I get is quite thick. enter image description here

is it possible to make it thinner?

Upvotes: 4

Views: 612

Answers (1)

Alfonso
Alfonso

Reputation: 8482

You can change the thickness of the line at this part of your code:

shapelayer.lineWidth = 7.0;

Change the 7.0 to whatever thickness you would like your line to have.

Upvotes: 5

Related Questions