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 .addRippleTouchHandler method
- Add ripple view by .addRipple method
import SwiftUIRippleEffect
var button1: some View {
VStack {
let rippleViewModel = RippleViewModel() // 1
Button(action: {
}, label: {
HStack {
Spacer()
Text("Title 1").padding()
Spacer()
}
.addRippleTouchHandler(viewModel: rippleViewModel) // 2
})
.buttonStyle(EmptyStyle())
.background(
Capsule()
.foregroundColor(.yellow)
.rippleEffect(color: .gray,
maxScale: 0.9,
viewModel: rippleViewModel,
clipShape: Capsule()) // 3
)
}.padding()
}
You can find more examples inside /Examples
folder.
MIT