首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >减慢UIDynamicAnimator的动画速度

减慢UIDynamicAnimator的动画速度
EN

Stack Overflow用户
提问于 2014-09-29 00:48:49
回答 1查看 666关注 0票数 0

我想放慢UIDynamicAnimator生成动画的速度,这样我就可以微调我的UIDynamicBehaviors了。

在ios模拟器中,Debug菜单下有一个菜单选项,标签为“在最前面的应用程序中切换慢速动画”。

但是,此选项似乎对UIDynamicAnimator生成的动画没有影响。有没有其他方法可以达到我的目标?

EN

回答 1

Stack Overflow用户

发布于 2015-02-09 16:40:35

您可以更改在动画中指定的力,以使移动速度变慢。例如,可以更改重力大小以减慢加速度:

代码语言:javascript
复制
    self.animator = UIDynamicAnimator(referenceView: self.view)
    var gravity = UIGravityBehavior(items: [animatedView])
    gravity.magnitude = 0.5

如果正在进行碰撞,还可能会增加摩擦力和/或弹性来减慢速度,尽管在某些情况下这可能会影响轨迹:

代码语言:javascript
复制
    let bounceProperties = UIDynamicItemBehavior(items: [animatedView])
    bounceProperties.elasticity = 0.5
    bounceProperties.friction = 0.2

    var collision = UICollisionBehavior(items: [animatedView])
    var boundaryId: NSMutableString = NSMutableString(string: "bottomBoundary")
    let boundaryPath = UIBezierPath(rect: boundaryFrame)
    collision.addBoundaryWithIdentifier(boundaryId, forPath: boundaryPath)

    // Start animating
    animator.addBehavior(gravity)
    animator.addBehavior(collision)
    animator.addBehavior(bounceProperties)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26087217

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档