Showing posts with label usingSpringWithDamping. Show all posts
Showing posts with label usingSpringWithDamping. Show all posts

Sunday, February 12, 2017

Friday, November 4, 2016

Animation With Spring (Bounce)


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)

SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...