Skip to content

Instantly share code, notes, and snippets.

@saoudrizwan
Last active August 24, 2017 11:30
Show Gist options
  • Select an option

  • Save saoudrizwan/db870c58646fe45aabade0ae7901d33e to your computer and use it in GitHub Desktop.

Select an option

Save saoudrizwan/db870c58646fe45aabade0ae7901d33e to your computer and use it in GitHub Desktop.
import UIKit
let impactFeedbackGenerator: (
light: UIImpactFeedbackGenerator,
medium: UIImpactFeedbackGenerator,
heavy: UIImpactFeedbackGenerator) = (
UIImpactFeedbackGenerator(style: .light),
UIImpactFeedbackGenerator(style: .medium),
UIImpactFeedbackGenerator(style: .heavy)
)
// Prepare shortly before playing
impactFeedbackGenerator.light.prepare()
impactFeedbackGenerator.medium.prepare()
impactFeedbackGenerator.heavy.prepare()
// Play the haptic signal
impactFeedbackGenerator.heavy.impactOccurred()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment