I would like to place N views, say Circle() for example, around the perimeter of a rounded rectangle. They need to be evenly spaced. I could figure out the math to do this if the main path was a circle by using the circumference and radius of the circle. But there's no such formula for rounded rectangles.
So I'm wondering if there's a way to extract the path from the rounded rect, or really any general shape, and place N evenly spaced views along the path. Even if I have to draw the rectangle path manually, I guess the main question is how to place views along that path.
This can be done by trimming the path and then using
currentPoint
to find the position along the path. According to the documentation, this returnsWhen you trim from 0 to 0, the
currentPoint
point is nil. So the loop needs to use a closed range from1...nDots
instead of0..<nDots
: