总共两种方式:
- AudioToolbox 的 kSystemSoundID_Vibrate
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
- UIImpactFeedbackGenerator(iOS 10.0 以上)
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
style 参数取值如下:
extension UIImpactFeedbackGenerator {
public enum FeedbackStyle : Int, @unchecked Sendable {
case light = 0
case medium = 1
case heavy = 2
@available(iOS 13.0, *)
case soft = 3
@available(iOS 13.0, *)
case rigid = 4
}
}
网友评论