Post

Replies

Boosts

Views

Activity

resize UIDynamicItem
I'm trying to use UIKit Dynamics together with animations. The object (in my case just a simple square view) is resized, but the Collision-boundaries are not refreshed to reflect the new size of the square.With the following simple ViewController my problem can be reconstructed:class UIDynamicsTestViewController: UIViewController { var animator: UIDynamicAnimator! var collision: UICollisionBehavior! var gravity: UIGravityBehavior! override func viewDidLoad() { super.viewDidLoad() let square = UIView(frame: CGRect(x: 100, y: 100, width: 200, height: 200)) square.backgroundColor = UIColor.blueColor() view.addSubview(square) animator = UIDynamicAnimator(referenceView: self.view) collision = UICollisionBehavior(items: [square]) collision.translatesReferenceBoundsIntoBoundary = true animator.addBehavior(collision) gravity = UIGravityBehavior(items: [square]) animator.addBehavior(gravity) UIView.animateWithDuration(1.0, animations: { square.frame.size = CGSize(width: 50,height: 50) }) }}This example makes the square fall down thru gravity and bounce a little bit on the bottom border of the screen. At the same time the square shrinks.The Problem is that the square will not 'land' directly on the bottom border but float approximately 100 pixels over the border as if it didn't resizeHow can I refresh the boundaries used for collision?
1
0
785
Apr ’16