A swift implementation of Facebooks shimmer effect.
This project is no longer under active development. It's stable and should still be good to use for a number of years. I'm moving my efforts into SwiftUI.
Download the .zip from this repo and drag the Shimmer folder into your project.
github "BeauNouvelle/ShimmerSwift" to your Cartfile.
pod 'ShimmerSwift' to your Podfile.
In Xcode 11 you can add packages by going to
File > Swift Packages > Add Package Dependency. Copy in this repos URL and go from there.
Shimmer is super easy to get started with.
Simply create a
ShimmeringLayer and add your content.
// Setup ShimmeringView let shimmerView = ShimmeringView(frame: self.view.bounds) self.view.addSubview(shimmerView) // Setup the view you want shimmered let label = UILabel(frame: shimmerView.bounds) label.text = "This is my shimmering text" // Add the view you want shimmered to the `shimmerView` shimmerView.contentView = label // Start shimmering shimmerView.isShimmering = true // To stop shimmering. shimmerView.isShimmering = false
All customizable properties are well documented in code, and are reproduced below.
The content view to be shimmered
true to start shimmer animation, and
false to stop. Detaults to
The speed of the shimmer animation in points per second. The higher the number, the faster the animation.
The highlight length of the shimmer. Range of [0,1], defaults to
The direction of the shimmer animation.
.right, which will run the animation from left to right.
The time interval between shimmers in seconds. Defaults to 0.4.
The opacity of the content during a shimmer. Defaults to
The opacity of the content when not shimmering. Defaults to
The duration of the fade used when the shimmer begins. Defaults to
The duration of the fade used when the shimmer ends. Defaults to