HowTo add Shimmering Animation Effect to UIView

Yi 🐍🐏
2 min readMar 1, 2022
Photo by Maxwell Nelson on Unsplash

It’s a good practice for developer to add some shimmering animation effect to certain views, especially when it’s loading images or videos. Start a shimmering animation will help users understand the app is loading something from internet or local disk, or working on some heavy job. So, without leaving users in the dark, users would expect something coming shortly at that placeholder where shimmering happening now.

Let’s take a look at final result first. (Thanks to swifter on reddit.com for the wonderful suggestions , and beautiful gif generation tool https://gif.ski/.)

Here, I have attached a piece of swift code, which extends UIView, so this isShimmering property could be applied to any UIView subclasses instance.

How to use this code:

  1. Add this extension code to your project.
  2. Simply, assign true/false to the UIView or subclasses…

--

--