我想放慢UIDynamicAnimator生成动画的速度,这样我就可以微调我的UIDynamicBehaviors了。
在ios模拟器中,Debug菜单下有一个菜单选项,标签为“在最前面的应用程序中切换慢速动画”。
但是,此选项似乎对UIDynamicAnimator生成的动画没有影响。有没有其他方法可以达到我的目标?
发布于 2015-02-09 16:40:35
您可以更改在动画中指定的力,以使移动速度变慢。例如,可以更改重力大小以减慢加速度:
self.animator = UIDynamicAnimator(referenceView: self.view)
var gravity = UIGravityBehavior(items: [animatedView])
gravity.magnitude = 0.5如果正在进行碰撞,还可能会增加摩擦力和/或弹性来减慢速度,尽管在某些情况下这可能会影响轨迹:
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)https://stackoverflow.com/questions/26087217
复制相似问题