This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pushContinousBehaviour = UIPushBehavior(items: [targetView], mode: .continuous) | |
animator.addBehavior(pushContinousBehaviour) | |
// Using pushDirection | |
pushContinousBehaviour.pushDirection = CGVector(dx: 50, dy: 0) | |
// Using magnitude and angle | |
pushContinousBehaviour.magnitude = 50 | |
pushContinousBehaviour.angle = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let animator = UIDynamicAnimator(referenceView: containerView) | |
let gravityBehaviour = UIGravityBehavior(items: [targetView]) | |
gravityBehaviour.magnitude = 1.0 // gravity on earth | |
animator.addBehavior(gravityBehaviour) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
let containerView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 320.0, height: 480.0)) | |
// Play with containerView | |
let targetView = UIView(frame: CGRect(x: containerView.bounds.midX, | |
y: containerView.bounds.midY, | |
width: 50.0, | |
height: 50.0)) |
NewerOlder