Code Example
UIView.animate(withDuration: 0.2, delay: 0, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.5, options: .curveEaseOut, animations: { // Your animation }, completion: nil)
Parameters
- withDuration - How long the animation should last
- delay - How long to wait until starting the animation
- usingSpringWithDamping - Applies damping to the spring (bounce). Using 1 will completely damp out the spring so the animation just slides into place and stops. Lower the damping for more bounce (example: 0.1 - 0.9).
- initialSpringVelocity - How fast you want the initial animation to happen. Using 1 will start it fast, 0 is normal. Apple says, "You'll typically want to pass 0 for the velocity."
- options:
- curveEaseInOut - Start slow, speed up, then slow down
- curveEaseIn - ("In" specifies the start of the animation) Start slow, speed up, then suddenly stop
- curveEaseOut - ("Out" specifies the end of the animation) start fast, then slow down until stop
- curveLinear - Constant speed throughout animation
(Xcode 8, Swift 3.0)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.