Created
January 5, 2023 23:50
-
-
Save navsing/e0a7bdd8a4b4ee98a4279f4392bad828 to your computer and use it in GitHub Desktop.
Card Shimmer Sample
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
struct CardShimmer : View { | |
@State var show = false | |
var center = (UIScreen.main.bounds.width / 2) + 110 //removing padding with this hack | |
var body : some View{ | |
ZStack{ | |
Color.black.opacity(0.08) | |
.frame(height: 250) | |
.cornerRadius(20) | |
Color.white | |
.frame(height: 250) | |
.cornerRadius(20) | |
.mask( | |
Rectangle() | |
.fill( | |
LinearGradient(gradient: .init(colors: [.clear,Color.white.opacity(0.5),.clear]), startPoint: .top, endPoint: .bottom) | |
) | |
.rotationEffect(.init(degrees: 60)) | |
.offset(x: self.show ? center : -center) | |
) | |
} | |
.onAppear { | |
withAnimation(Animation.default.speed(0.20).delay(0).repeatForever(autoreverses: false)){ //same animation as text shimmer | |
self.show.toggle() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment