Shimmer is an easy way to add a shimmering effect to any view in your app. It's useful as an unobtrusive loading indicator.
Shimmer was originally developed to show loading status in Paper (no longer online).
To use Shimmer, create a ShimmeringView or ShimmeringLayer and add your content. To start shimmering, set the shimmering property to true.
An example of making a label shimmer:
let shimmeringView = ShimmeringView(frame: view.bounds)
view(addSubview: shimmeringView)
let loadingLabel = UILabel(frame: shimmeringView.bounds)
loadingLabel.textAlignment = .center
loadingLabel.text = "Shimmer"
shimmeringView.contentView = loadingLabel
// Start shimmering.
shimmeringView.isShimmering = trueThere's also an example project. In the example, you can swipe horizontally and vertically to try various shimmering parameters, or tap to start or stop shimmering. (To build the example locally, you'll need to open Shimmering.xcworkpace rather than the .xcodeproj.)
There are following options:
- Swift Package Manager. Add
https://github.com/eugeneego/Shimmer.gitto yourPackage Dependenciesin Xcode. Or add.package(url: "https://github.com/eugeneego/Shimmer.git", from: "1.0.0")todependenciesblock inPackage.swiftfile. - Carthage. Add
github "eugeneego/Shimmer"to yourCartfile. - Cocoapods. Add
pod 'Shimmer', :git => 'https://github.com/eugeneego/Shimmer.git'to yourPodfile. - Manually. Just add
Shimmering/ShimmeringView.swiftinto your Xcode project. Slightly simpler, but updates are also manual.
Shimmer requires iOS 11 or later.
Shimmer uses the CALayer.mask property to enable shimmering, similar to what's described in John Harper's 2009 WWDC talk (unfortunately no longer online). Shimmer uses CoreAnimation's timing features to smoothly transition "on-beat" when starting and stopping the shimmer.
We have a version of Shimmer for Android, too! It's also available on GitHub.
See the CONTRIBUTING file for how to help out.
Shimmer is BSD-licensed.
