๐นPressing Animation & Haptic Feedback SwiftUI Button
File โ Swift Packages โ Add Package Dependancy..
.package(url: "https://github.com/Changemin/PressableButton", from: "1.1.0")
PressableButton(action: { YOUR ACTION }) {
// YOUR VIEW
}
action
: Functions to executePressableButton(action: { YOUR ACTION }) {
// YOUR VIEW
}.accentColor(_ color: color)
.cornerRadius(_ amount: CGFloat)
.frame(width: CGFloat, height: CGFloat)
.enableHaptic(intensity: UIImpactFeedbackGenerator.FeedbackStyle)
.disableHaptic()
.accentColor()
: Accent color.cornerRadius()
: Corner Radius of the button.frame()
: Size of the button.enableHaptic()
: Enable haptic effect with insensity(.heavy
, .medium
, .light
, .rigid
, .soft
).disableHaptic()
: Disable haptic effectimport PressableButton
struct ContentView: View {
var body: some View {
PressableButton(action: {
print("Button pressed")
}) {
Text("Simple Example").foregroundColor(.white)
}
}
}
import PressableButton
struct ContentView: View {
var body: some View {
PressableButton(action: {
print("Button pressed")
}) {
Text("PUSH ME !").foregroundColor(.white)
}
.enableHaptic(.soft)
.accentColor(.orange)
.cornerRadius(0)
}
}
FlatStyle
, PushButtonStyle
, etcPressableButton is available under the MIT license. See the LICENSE
file for more info.