android - 是否有等效于 iOS 的 FastOutSlowInInterpolator?

标签 android ios interpolation androidx

有没有等价于FastOutSlowInInterpolator的适用于 iOS?我最近接触了 AndroidX,非常喜欢这个插值器。我找到了 source code也适用于它,但不知道如何将其转换为 iOS 实现。

最佳答案

如果您使用的是 UIViewPropertyAnimator,则您需要的曲线是 .easeInOut ,并且您可以在创建动画器时将其作为 curve 参数传递:

let animator = UIViewPropertyAnimator(duration: 0.4, curve: .easeInOut) {
    // Animations
}

如果对这个系统曲线不满意,可以关注this answer并使用 this handy website复制 FastOutSlowInInterpolator 的控制点。

作为FastOutSlowInInterpolator文档状态:

Interpolator corresponding to fast_out_slow_in. Uses a lookup table for the Bezier curve from (0,0) to (1,1) with control points: P0 (0, 0) P1 (0.4, 0) P2 (0.2, 1.0) P3 (1.0, 1.0)

因此,在您的特定情况下,您正在寻找这样的东西:

let timingParameters = UICubicTimingParameters(
    controlPoint1: CGPoint(x: 0.4, y: 0),
    controlPoint2: CGPoint(x: 0.2, y: 1)
)
let animator = UIViewPropertyAnimator(duration: 0.4, timingParameters: timingParameters)

或者这个:

let animator = UIViewPropertyAnimator(
    duration: 0.4,
    controlPoint1: CGPoint(x: 0.4, y: 0),
    controlPoint2: CGPoint(x: 0.2, y: 1)
) {
    // Animations
}

关于android - 是否有等效于 iOS 的 FastOutSlowInInterpolator?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64438742/

相关文章:

matlab - Scipy interp1d 和 matlab interp1

java - Android相关的蜜 jar 研究

安卓开发日志

ios - 在 Swift 中使用 UITapGestureRecognizer 的参数

android - 在 flutter 中使用 MVP 架构的 Chopper

python - FFT2 中心对称物体的非零虚部?

python - 根据组插入 DataFrame 中的特定条目

android:进程和进程名称

android - 如何在 android 中获取有用的/个人文件?

ios - Swift,如何在遵循 MVC 的同时声明需要实例成员的方法