How can you make a device vibrate at different frequencies with swift?

I want to make an application that makes the phone vibrate at different frequencies. How can I control the vibration frequency of the phone?

+6
source share
1 answer

I don’t know if this helps, but in my case, I wanted for some reason I had a longer vibration, and I created this extension for him.

extension UIViewController { func vibrate(_ style: UIImpactFeedbackGenerator.FeedbackStyle = .heavy) { let impactFeedbackgenerator = UIImpactFeedbackGenerator(style: style) impactFeedbackgenerator.prepare() impactFeedbackgenerator.impactOccurred() } func vibrateBomb() { for i in 0...4 { DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/3) { self.vibrate() } DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/5) { self.vibrate() } DispatchQueue.main.asyncAfter(deadline: .now() + Double(i * 1)/8) { self.vibrate() } } } } 
0
source

Source: https://habr.com/ru/post/1259366/


All Articles