[英]slowing down animation of UIDynamicAnimator
我想放慢UIDynamicAnimator生成的动画,以便可以微调UIDynamicBehaviors。
在ios模拟器中,“调试”菜单下有一个菜单选项,标签为“切换最前端应用中的慢速动画”。
但是,此选项似乎对UIDynamicAnimator产生的动画没有影响。 还有其他方法可以实现我的目标吗?
您可以更改在动画中指定的力,以使运动变慢。 例如,您可以更改重力大小以减慢加速度:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.