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/

相关文章:

android - 是否有任何 flutter 插件可以在 android 中播放实时流媒体视频(.m3u8)?

android - 如何将数据添加到应用程序快捷方式 Intent

android - 如何在Kotlin中实现List <data class>(子列表)的可拆分的实现?

ios - 呈现没有 Storyboard的模态视图 Controller

python - 在Python极坐标中将时间序列数据从一个df插值到另一个df的时间轴

python - 尝试在 Python 中插入直方图函数的输出

android - 如何在 Android 中完全显示多行 editText(部分被键盘隐藏)

iOS - WebView 警告 : Assigning to 'id<UIWebViewDelegate>' from incompatible type

ios - 2.23 - 应用程序必须遵循 iOS 数据存储指南,否则将被拒绝

python - 哪种插值最适合调整图像大小?