문제

I have seen many examples of drawing a dashed line for iOS. I would like to draw a dotted line made of circles that follow my path. I want to use a shape layer so I can animate the stroke to simulate it being drawn onscreen.

Any suggestions for drawing little dots that follow my uibezierpath?

Conversely - is this not possible? If so can I array a bunch of circles along a path and then iterate through the array of circles making them visible? But how to array circles along a bezier?

도움이 되었습니까?

해결책

I was able to draw a dashed line with circles between two uiviews:

// dotted line
    CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
    CGContextSetLineWidth(ctx, 10); // relevant code
    CGFloat dash[] = {0.0, 10*2}; // relevant code
    CGContextSetLineCap(ctx, kCGLineCapRound); // relevant code
    CGContextSetLineDash(ctx, 0.0, dash, 2);
    CGContextMoveToPoint(ctx, view.center.x, view.center.y);
    CGContextAddLineToPoint(ctx, anotherView.center.x, anotherView.center.y);
    CGContextStrokePath(ctx);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top