gpt4 book ai didi

ios - 模仿 Apple 的 UIViewAnimationOptionCurveEaseInOut 数学方程?

转载 作者:可可西里 更新时间:2023-11-01 04:42:03 29 4
gpt4 key购买 nike

我想创建一个看起来像 Apple 的 CurveEaseInOut 一样的动画,以便我的应用程序看起来一致。问题是这个特定的动画不能使用 UIView animate 方法。我必须在每一帧手动操作位置。比如我得到一个时间T,我需要输出那个时间点的中心C。我不想使用线性关系(例如 C = T),而是希望它像 Apple 一样缓入缓出。

Apple 为该动画选项使用了哪个曲线方程?

我假设曲线看起来类似于:(取自 this question)

enter image description here

如果是这样的话,看起来我应该可以调整 Cubic Hermite spline具有正确常数的方程并得到相同的结果。问题是 Apple 使用哪些常量?

最佳答案

正如碳酸 (H2CO3) 所指出的,问题在于 Apple 使用哪些控制点。

假设它与 Core Animation 中的默认计时功能相同,您可以从文档中获取控制点:

kCAMediaTimingFunctionDefault Specifies the timing function used as the default by most animations. It approximates a Bézier timing function using the control points [(0.0,0.0), (0.25,0.1), (0.25,0.1), (1.0,1.0)]. By using this constant you ensure that your animations will use the current default timing.


编辑

既然你提到了自定义动画,我强烈建议你观看 Animation Custom Layer Properties presentation by Rob Napier .您可以从 Core Animation 中获益,同时仍然可以制作您的自定义动画。 (观看整个演示文稿。它有助于理解大部分 Core Animation)

关于ios - 模仿 Apple 的 UIViewAnimationOptionCurveEaseInOut 数学方程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16351966/

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