DEV Community

Slavenko Miljic
Slavenko Miljic

Posted on

1 2

A numeric UILabel that animates value change

Slavenko Miljic - SMCounterLabel

https://github.com/slavenko/SMCounterLabel

This is a fun project of mine that I started working on because i wanted to use something similar on a project I was working on at that time. You can see this kind of UI interaction in a lot of mockups for financial apps, but I couldn't find anything similar already coded (at least for Swift) so I had to make it myself.

It works basically by creating a separate label for each of the characters in a string, calculating it's position based on a selected font, and then just animating the number change for each label separately, until it reaches the desired value.

Just putting this out there, maybe someone might find it useful.

All suggestions and critiques are more than welcome. Happy coding.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay