gpt4 book ai didi

swift - watchOS2 animateWithDuration 启动缓慢并加速

转载 作者:行者123 更新时间:2023-11-28 08:31:56 24 4
gpt4 key购买 nike

我正在尝试通过调用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com