UIView animation block: if duration is 0, is it the same as without animation?

ios, objective-c, uiview, uiviewanimation

Solution

Yes, since the duration is zero, the transition will effectively by instantaneous.

Problem

I need to handle a case where you can do something with or without animation, instead of: ``` if (animation) { [UIView animateWithBlock:^(){...}]; } else { ... } ``` I want to do: ``` [UIView animateWithBlock:^(){...} duration:(animation ? duration : 0)] ``` but not sure if it works, even if it does, is there any overhead for using this instead of directly change the view? Thanks

Original source