How to make iPhone vibrate using Swift?

后端 未结 11 1539
天命终不由人
天命终不由人 2020-11-29 16:08

I need to make the iPhone vibrate, but I don\'t know how to do that in Swift. I know that in Objective-C, you just write:

import AudioToolbox
AudioServicesPl         


        
11条回答
  •  自闭症患者
    2020-11-29 16:19

    Other vibration types:

    import AudioToolbox
    
    AudioServicesPlaySystemSound(1519) // Actuate "Peek" feedback (weak boom)
    AudioServicesPlaySystemSound(1520) // Actuate "Pop" feedback (strong boom)
    AudioServicesPlaySystemSound(1521) // Actuate "Nope" feedback (series of three weak booms)
    

    More About Vibration - http://www.mikitamanko.com/blog/2017/01/29/haptic-feedback-with-uifeedbackgenerator/

提交回复
热议问题