I've got a bit of a challenging thing I am trying to build.
Basically, I got this scenario here:
I am able to draw the dotted line thanks to this Stackoverflow answer:
Draw dotted (not dashed!) line, with IBDesignable in 2017
The dotted line drawing is done inside:
-(void)drawRect:(CGRect)rect
{
[self drawDottedLineFromStartingPoint:self.mainPhoto.center ToEndPoint:self.photo1.center];
[self drawDottedLineFromStartingPoint:self.mainPhoto.center ToEndPoint:self.photo2.center];
[self drawDottedLineFromStartingPoint:self.mainPhoto.center ToEndPoint:self.photo3.center];
[self drawDottedLineFromStartingPoint:self.mainPhoto.center ToEndPoint:self.photo4.center];
[self drawDottedLineFromStartingPoint:self.mainPhoto.center ToEndPoint:self.photo5.center];
}
-(void)drawDottedLineFromStartingPoint:(CGPoint)startPoint ToEndPoint:(CGPoint)endPoint
{
UIBezierPath *path = [[UIBezierPath alloc] init];
[path moveToPoint:startPoint];
[path addLineToPoint:endPoint];
path.lineWidth = 4;
CGFloat dashes[] = {path.lineWidth * 0, path.lineWidth * 2};
[path setLineDash:dashes count:2 phase:0];
path.lineCapStyle = kCGLineCapRound;
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(ctx, [ThemeManager mediumTextColor].CGColor);
[path stroke];
}
The problem I am facing is that each smaller circles animate in by falling down into place.
The way I am animating the smaller circle is by using something like:
CGAffineTransformMakeTranslation(0, 50);
When I do that, the dotted lines is drawn from the big circle to the final resting position of the smaller circle, the dotted lines doesn't "follow" the smaller circle as it's being animated and falling down.
So what you see is this:
Is there any easy solution to what I am trying to achieve ? I've tried thinking of using NSTimer and calculating the hypotenuse length, divide by a duration, but I didn't get very far :D