Sdanson
Sdanson

Reputation: 155

How to recreate Haptic Feedback Vibration when you long press on app icon

How can I recreate the exact vibration that happens when you hold down on an app icon like this in swift?enter image description here

The same vibration can be felt when you swipe on a message on Facebook messenger to reply to it.

Upvotes: 1

Views: 1631

Answers (1)

rodskagg
rodskagg

Reputation: 3937

You can use a UIFeedbackGenerator for this, for example:

UINotificationFeedbackGenerator().notificationOccurred(.success)

or

UISelectionFeedbackGenerator().selectionChanged()

Upvotes: 4

Related Questions