ios - 反馈振动像苹果呼吸一样 swift

标签 ios swift apple-watch feedback vibration

我试图在 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/

相关文章:

ios - watch 操作系统 : Should UI updates from the extension be called on the main thread?

ios - 即使我使用了 AppGroup,我的 Iwatch 也无法获取从 ios 应用程序保存的数据

android - 插入移动操作系统核心应用程序

xcode - 缺少用于将 core-plot 文档安装到 xCode 中的 com.CorePlot.Framework.docset 包

ios - 将 firebase 操作放入哪个 GCD 队列? swift 4

ios - 如何从pdf文件中删除注释

javascript - iOS 为带有嵌入推文的 html 字符串计算正确的 WKWebview 高度

ios - 避免在 App Delegate 中重复执行代码

iOS Swift AVAudioPlayer 播放完毕后如何将 currentTime 重置为零

ios - 将数据传递给 Apple Watch 应用程序