Metal Ripple
A beautiful ripple effect using Metal shaders with SwiftUI integration
Credits
This ripple effect implementation is based on the original code from DesignCode. Please visit their website to see more awesome tutorials and courses!
Visit DesignCode TutorialPreview
Code
1import SwiftUI23struct MetalRippleImageView: View {4 @State var counter: Int = 05 @State var origin: CGPoint = .init(x: 0.5, y: 0.5)6 7 var body: some View {8 Image("ripple")9 .resizable()10 .aspectRatio(contentMode: .fit)11 .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))12 .onPressingChanged { point in13 if let point {14 origin = point15 counter += 116 }17 }18 .modifier(RippleEffect(at: origin, trigger: counter))19 .padding(40)20 .frame(maxWidth: .infinity, maxHeight: .infinity)21 }22}2324#Preview {25 MetalRippleImageView()26}