我试图在 iPhone 上重现 Apple Watch 的呼吸,但无法重现 watch 在呼吸时向用户提供的反馈振动。我尝试过这个:
for _ in 1...5 {
AudioServicesPlayAlertSound(SystemSoundID)
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
sleep(1)
}
但是振动太重,并且(由于 for 循环)不像 Apple Watch 那样流畅。
最佳答案
您可以简单地使用 Taptic 引擎来使用 Haptics,以获得更轻松的反馈。
swift 3
WKInterfaceDevice.current.playHaptic(.success)
Objective-C
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticType.Success];
有关更多信息和可能的枚举值,请访问 here .
关于ios - 反馈振动像苹果呼吸一样 swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41805864/