Show HN: TapeMeasure – Swift class for creating segmented, labeled lines in UI TapeMeasure is a utility class, written in Swift, for generating a visual tape measure, or any other graphical elements that need layout in a measured sequence. I created this class to help with a pet project I'm working on, where I needed to generate segmented, labeled lines to use as axes on charts and graphs. It occurred to me that this seems to be a pretty common task, involving a lot of boilerplate code and tedious calculations. Why not decouple the code and move it into a dedicated class? It's self-contained, nice and simple, and easy to unit test. It can also handle a lot of tweaks to the "tape measure", such as boundary clipping and shifting offsets. It's especially good for animation, where you can just change a parameter or two during animation, and call for the re-calculated data to re-render your measured line. That makes it great for animated sliding and scaling effects. Anyway, enjoy! https://ift.tt/MlTH0Wq July 29, 2022 at 11:09PM
0 Comments