Cool ripple effect on you SwiftUI view.
- easy to use for regular button
- long press and gesture support
Swift Package Manager:
https://github.com/Jnis/SwiftUIRippleEffect.git
- Make a shared RippleViewModel
- Add touch handler by .rippleTouchHandler method
- Add ripple effect view by .rippleEffect method
import SwiftUIRippleEffect
var button1: some View {
VStack {
let rippleViewModel = RippleViewModel() // 1
Button(action: {
}, label: {
HStack {
Spacer()
Text("Title 1").padding()
Spacer()
}
.rippleTouchHandler(viewModel: rippleViewModel) // 2
})
.buttonStyle(EmptyStyle())
.background(
Capsule()
.foregroundColor(.yellow)
.rippleEffect(color: .gray,
rippleViewModel: rippleViewModel,
clipShape: Capsule()) // 3
)
}.padding()
}
You can find more examples inside /Examples
folder.
MIT