diff --git a/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Extensions.swift b/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Extensions.swift index 7fb7bf1..3f0183b 100644 --- a/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Extensions.swift +++ b/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Extensions.swift @@ -58,11 +58,13 @@ extension UIView { public func setTemplateWithSubviews(_ template: Bool, color: UIColor? = nil, animate: Bool = true, - viewBackgroundColor: UIColor? = nil) { + viewBackgroundColor: UIColor? = nil, + animationSpeed: CGFloat = 1.25) { allTemplateViews.forEach { $0.setTemplate(template, baseColor: color) if animate { - $0.setShimmeringAnimation(template, viewBackgroundColor: viewBackgroundColor) + $0.setShimmeringAnimation(template, viewBackgroundColor: viewBackgroundColor, + animationSpeed: animationSpeed) } } } diff --git a/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Shimmer.swift b/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Shimmer.swift index a178660..6dc62b8 100644 --- a/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Shimmer.swift +++ b/Sources/UIView-Shimmer/Sources/UIView+Extensions/UIView+Shimmer.swift @@ -13,7 +13,7 @@ extension UIView { /// - Parameters: /// - animate: Specifies the animation is on/off. /// - viewBackgroundColor: The `backgroudColor` of specified views superview. - func setShimmeringAnimation(_ animate: Bool, viewBackgroundColor: UIColor? = nil) { + func setShimmeringAnimation(_ animate: Bool, viewBackgroundColor: UIColor? = nil, animationSpeed: CGFloat) { let currentShimmerLayer = layer.sublayers?.first(where: { $0.name == Key.shimmer }) if animate { if currentShimmerLayer != nil { return } @@ -47,7 +47,7 @@ extension UIView { animation.fromValue = [-1.0, -0.5, 0.0] animation.toValue = [1.0, 1.5, 2.0] animation.repeatCount = .infinity - animation.duration = 1.25 + animation.duration = animationSpeed gradientLayer.add(animation, forKey: animation.keyPath) } }