swift - watchOS2 animateWithDuration 启动缓慢并加速

标签 swift animation watchos-2

我正在尝试通过调用 WKInterfaceController 类的 animateWithDuration 为我的 watchOS2 应用程序中的组宽度设置动画。这个想法是向用户显示一条水平线,该水平线在一段时间内从右到左减小其宽度(类似于计时器):

self.timer.setWidth(100)
self.animateWithDuration(NSTimeInterval(duration)) {
    self.timer.setWidth(0)
}

但是我看到动画一开始速度就非常慢然后增加。当动画即将停止时(当计时器宽度接近 0 时)动画再次变慢。 我希望速度在整个动画持续时间内保持不变。

有没有人遇到过这个问题?任何帮助表示赞赏!谢谢

最佳答案

WatchOS 2 不提供指定计时功能的方法,因此动画仅限于使用 EaseInEaseOut 曲线(开始时速度较慢,然后加速,最后减速)。

你可以试试 using Core Graphics to render the line ,或使用一系列 WKInterfaceImage 帧来平滑地为线条设置动画。

关于swift - watchOS2 animateWithDuration 启动缓慢并加速,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38680373/

相关文章:

swift - CAShapeLayer + UIBezierPath 填充动画是不填充形状而不是填充?

iOS 近乎实时地从 Apple Watch 获取心率

ios - 使用 CoreData 时如何与 Watch OS 2 共享数据以显示在 WKInterfaceTable 中

ios - 从 iOS 应用程序启动 watchOS2 应用程序

swift - 解析查询与 pfuser 不匹配点

ios - 无法在我的 iOS 应用程序中读取 XML 文件

swift - 检测 WKWebView 中的图片点击?

jquery - 如何循环 .animate JQuery

jquery - 如何将 div 设置为可见性 :hidden to display using jQuery?

css - href 乱七八糟的 css 动画