Skip to main content
  1. Blog/

Ready to Rumble

app programming Swift Talk Dim Sum
Phil Chu
Phil Chu
Making software since the 80s

Way back when I worked on a GameCube game, one of the trickier things was controlling the rumble feature on the controller. You had to start and stop the rumble and feed it a rumble signal for the type of rumble you wanted. Often if there was a bug the rumble would never stop.

Now, after noticing some Mastodon iOS apps providing haptic feedback on some taps, e.g. favoriting a post, or even upon scrolling, I decided to try adding a little rumble when favoriting a dish in my Talk Dim Sum app.

Turns out to be straightforward: create a UIImpactFeedbackGenerator with the type of rumble you want (ranging from light to heavy, or soft to rigid), and then call impactOccurred on it.

The class and method names are a bit clunky, so I created a little wrapper so that lets me call Rumble.lightly() and so forth.

public class Rumble {
        public static var light = 
            UIImpactFeedbackGenerator(style: .light)
        public static func lightly() {