UIViewPropertyAnimator在iOS10和iOS11上反转动画的不同行为。 `isReversed`和`fractionComplete`属性的错误? [英] UIViewPropertyAnimator different behaviour on iOS10 and iOS11 reversing an animation. Bug on `isReversed` and `fractionComplete` properties?

查看:172
本文介绍了UIViewPropertyAnimator在iOS10和iOS11上反转动画的不同行为。 `isReversed`和`fractionComplete`属性的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


问题

在iOS10和iOS11上运行相同的代码我的UIViewPropertyAnimator在更改后就有不同的行为。 isReversed 属性。


iOS10上一切正常。动画问题发生在iOS11上

THE PROBLEM
Running the same code on iOS10 and iOS11 my UIViewPropertyAnimator has a different behaviour just after changing of his .isReversed property.

Everything is ok on iOS10. The animation problem happens on iOS11

条件

任何动画都适用,不仅适用于特定的动画,它可以通过观看动画和代码来验证。
它发生在模拟器和真实设备上。

CONDITIONS
It's true for any animations, not only for a particular one, and it is verifiable both by watching the animation and within the code. It happens both on simulators and real devices.

DETAILS

一旦创建了一个UIViewPropertyAnimator动画,在运行期间我只需调用 .pauseAnimation()并将 .isReversed 属性更改为 true 即可。之后我恢复动画调用:

DETAILS
Once created a UIViewPropertyAnimator with his animation, during its running I just call .pauseAnimation() and change the .isReversed property to true. After that I resume the animation calling:

continueAnimation(withTimingParameters parameters: UITimingCurveProvider?, durationFactor: CGFloat)

此时在iOS10上动画顺利改变了他的诗句,在iOS11上它会立即停止并自行反转有点帧滞后。

at this point on iOS10 the animation smoothly changes his verse, on iOS11 it stops immediately and reverses itself with a bit frames lag.

如果在代码中我检查 .fractionComplete 的值(在我的UIViewPropertyAnimator对象上调用它会让我回到完成状态)动画的百分比值,从0.0开始,到1.0结束)
刚刚 .continueAnimation(...


- 在iOS 10上,它会保留一段时间,就好像动画正在继续,只有在一段时间后跳到他的补充。


- 在iOS 11上它突然跳起来在他的补充
上发票b b在文档中有与此相关的非更新,只是UIViewPropertyAnimator的几个新属性但未使用,因为我是定位iOS10

If in code I check the value of .fractionComplete (called on my UIViewPropertyAnimator object it gives me back the completion of the animation in his percent value, starting from 0.0 and ending at 1.0) just after .continueAnimation(...

- On iOS 10 it remains for a few moments like if the animation is continuing and only after some fractions of time jumps to his complementary.

- On iOS 11 it jumps suddenly on his complementary


On the documentation there are non updates related to this, just a couple of new properties for the UIViewPropertyAnimator but not used because I'm targeting iOS10

可能是错误或我遗漏了什么东西!?

Could be a bug or I'm missing something!?

小更新:刚刚测试过,在iOS 11.0.1和iOS 11.1 beta1上的行为相同

Little update: just tested, same behaviour on iOS 11.0.1 and on iOS 11.1 beta1

在评论中链接,这只发生在非线性曲线上!

As linked in the comment, this happens only with a non-linear curve!

推荐答案

我已经打了很长一段时间,但后来我注意到 scrubsLinearly 属性被添加到<$ c iOS 11中的$ c> UIViewPropertyAnimator :

I have been fighting this for quite a while as well, but then I noticed the scrubsLinearly property that was added to UIViewPropertyAnimator in iOS 11:


默认为true。使动画师能够线性地或使用动画师的当前时间暂停和擦洗。

Defaults to true. Provides the ability for an animator to pause and scrub either linearly or using the animator’s current timing.

请注意,此属性的默认值为 true ,这似乎与使用非线性动画曲线产生冲突。这也可以解释为什么在使用线性定时功能时不存在该问题。

Note that the default of this property is true, which seems to cause a conflict with using a non-linear animation curve. That might also explain why the issue is not present when using a linear timing function.

scrubsLinearly 设置为 false ,动画师似乎按预期工作:

Setting scrubsLinearly to false, the animator seems to work as expected:

let animator = UIViewPropertyAnimator(duration: 0.25, curve: .easeOut) {
   ...
}
animator.scrubsLinearly = false

这篇关于UIViewPropertyAnimator在iOS10和iOS11上反转动画的不同行为。 `isReversed`和`fractionComplete`属性的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆