TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by BrunoRocha.
SlidingGradientView adds a sliding gradient to images in order to give the impression that something is loading. This is mostly meant to be used with images that resemble placeholders.
let image = UIImage(named: "placeholderEvents")
let placeholderView = SlidingGradientView(image: image)
//addSubview and constraints
placeholderView.startAnimating()
By default, SlidingGradientView uses a gradient that starts and end at RGB 248 248 248
and traverses 120% of the screen’s bounds in 0.7 seconds. You can edit these properties by creating a GradientProperties
object like this:
//Use UIColor.white.withAlphaComponent(0) for transparency, not UiColor.clear!
let gradientColors = [
GradientColor(color: UIColor.white.withAlphaComponent(0), location: 0),
GradientColor(color: UIColor.red, location: 0.5),
GradientColor(color: UIColor.white.withAlphaComponent(0), location: 1)
]
let slidingProperties = SlidingProperties(fromX: 0, toX: 100, animationDuration: 3)
let properties = GradientProperties(gradientWidth: 300, gradientColors: gradientColors, slidingProperties: slidingProperties)
let placeHolder2 = SlidingGradientView(image: image, properties: properties)
rockbruno, [email protected]
SlidingGradientView is available under the MIT license. See the LICENSE file for more info.