Show HN: TapeMeasure – Swift class for creating segmented, labeled lines in UI https://ift.tt/LnDF7lv
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/gX7L6w8 July 29, 2022 at 11:39PM
Comments