Find out the animation duration of the current animation block

animation, iphone, uiview, uiviewanimation

Solution

If you are targeting `iOS 9.0` or later, then you are looking for a class property of `UIView`, called `inheritedAnimationDuration`.

Usage:

let currentAnimationDuration = UIView.inheritedAnimationDuration

From Apple docs:

Summary

Returns the inherited duration of the current animation.

Discussion

This method only returns a non-zero value if called within a `UIView` animation block.

Problem

Inside a UIView animation block, is there a way to get the current animation's duration? ``` [UIView animateWithDuration:1.0 animations:^{ // float duration = ? }]; ```

Original source