We are gifted with a wide array of vibrations, from standard to customs. Let's take a look at the simple, already defined by apple vibrations.
Here are all the different types, working with iOS 15 and SwiftUI 3
let generator = UINotificationFeedbackGenerator()
VStack(alignment: .center, spacing: 30.0) {
Button(action: {
self.generator.notificationOccurred(.success)
}) {
Text("Notification - Success")
}
Button(action: {
self.generator.notificationOccurred(.error)
}) {
Text("Notification - Error")
}
Button(action: {
self.generator.notificationOccurred(.warning)
}) {
Text("Notification - Warning")
}
Button(action: {
let impactLight = UIImpactFeedbackGenerator(style: .soft)
impactLight.impactOccurred()
}) {
Text("Impact - Soft")
}
Button(action: {
let impactLight = UIImpactFeedbackGenerator(style: .light)
impactLight.impactOccurred()
}) {
Text("Impact - Light")
}
Button(action: {
let impactMed = UIImpactFeedbackGenerator(style: .medium)
impactMed.impactOccurred()
}) {
Text("Impact - Medium")
}
Button(action: {
let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
impactHeavy.impactOccurred()
}) {
Text("Impact - Heavy")
}
Button(action: {
let impactLight = UIImpactFeedbackGenerator(style: .rigid)
impactLight.impactOccurred()
}) {
Text("Impact - Rigid")
}
Button(action: {
let selectionFeedback = UISelectionFeedbackGenerator()
selectionFeedback.selectionChanged()
}) {
Text("Selection Feedback - Changed")
}
}
.padding(30)