objective-ciosuiviewuiviewanimation

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


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


Solution

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