Search code examples
swiftperformanceanimationviewled

LED Banner in Swift using views


I try to create an animated LED Banner. I can create letter views using a 5x8 digit display and make the the text move (https://github.com/drollig8/LEDBanner.git): The problem: with only a 10 letter text iOS will have to refresh 400 views 25 times per second. This kind of kills the CPU.

What can I do to make this endeavour more energy-saving?


Solution

  • Here is one approach for a right-to-left scrolling display.

    1. Create a custom view that can draw a 5x8 cell with its drawRect function.
    2. Use 11 of these views to represent your display. Add them as subviews to an appropriately size view.
    3. Every 1/25 of a second, move the 11 views and if the leftmost one has scrolled off the end, move it to the right side and update it with new letter data.