Created
May 26, 2025 01:19
-
-
Save hanrw/63a3d229d8b55511bd1488712aba672b to your computer and use it in GitHub Desktop.
shimmer effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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