如何在iPhone上循环振动

时间:2019-07-02 02:24:19

标签: ios swift

我如何循环这段代码:

AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))

使手机不断振动。

1 个答案:

答案 0 :(得分:0)

尝试一下:

func vibrate(current:Int, max: Int) {
    AudioServicesPlayAlertSoundWithCompletion(kSystemSoundID_Vibrate) {
        if current <= max {
            self.vibrate(current: current + 1, max: max)
        }
    }
}