spacecash21
spacecash21

Reputation: 1331

iOS - Set dashed line for a circle

CAShapeLayer *circle = [CAShapeLayer layer];

circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath;

// Configure the apperence of the circle
circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor whiteColor].CGColor;
circle.lineWidth = 1;      
// Add to parent layer
[[background layer] addSublayer:circle];

I have drawn a circle and added it as a sublayer. What I don't understand is how to make the circle line dashed? I have added my circle code above.

Upvotes: 7

Views: 5024

Answers (1)

rob mayoff
rob mayoff

Reputation: 385890

You need to set the lineDashPattern property of circle. For example:

circle.lineDashPattern = @[@2, @3];

Upvotes: 9

Related Questions