Skip to content

Animating

Evgenii Neumerzhitckii edited this page Jun 10, 2015 · 10 revisions
Drawing of White Dodo byFrederick William Frohawk

One can customize both hide and show animation for the notification bar before it is shown. You can either use one of the animation presets or provide your own animation closure.

Using animation presets

There are animation presets defined in DodoAnimations enum.

// Use existing animations
view.dodo.style.bar.animationShow = DodoAnimations.Rotate.show
view.dodo.style.bar.animationHide = DodoAnimations.SlideRight.hide
// Turn off animation
view.dodo.style.bar.animationShow = DodoAnimations.NoAnimation.show
view.dodo.style.bar.animationHide = DodoAnimations.NoAnimation.hide
// Customize duration of the animation
view.dodo.style.bar.animationShowDuration = 0.5
view.dodo.style.bar.animationHideDuration = 1

Provide a custom animation closure

You can use your own code for animating the bar view. If you do so make sure you call the onCompleted parameter.

view.dodo.style.bar.animationShow = { view, duration, locationTop, onCompleted in
  let actualDuration = duration ?? 0.5
  view.alpha = 0

  UIView.animateWithDuration(actualDuration,
    animations: {
      view.alpha = 1
    },
    completion: { finished in
      onCompleted()
    }
  )
}
Clone this wiki locally