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:
- Add this extension code to your project.
- Simply, assign
true
/false
to theUIView
or subclasses…