Skip to content

Instantly share code, notes, and snippets.

@hanrw
Created May 26, 2025 01:19
Show Gist options
  • Save hanrw/63a3d229d8b55511bd1488712aba672b to your computer and use it in GitHub Desktop.
Save hanrw/63a3d229d8b55511bd1488712aba672b to your computer and use it in GitHub Desktop.
shimmer effect
extension View {
func shimmer(
isActive: Bool = true,
speed: Double = 2.5,
color: Color =.white,
angle: Double = 0,
animateOpacity: Bool = false,
animateScale: Bool = false) -> some View {
Group {
if
isActive {
self.modifier(ShimmerViewModifier(
speed: speed,
color: color,
angle: angle,
animateOpacity: animateOpacity, animateScale: animateScale))
} else {
self
}
}
}
}
Example Usage :
State var
isActive = true RoundedRectangle(cornerRadius: 24)
.frame(width: 100, height: 100)
.shimmer(isActive: isActive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment