UIView's animateWithDuration delay not delaying animation
The delay
param of animateWithDuration:delay:options:animations:completion
specifies the delay before the animation occurs. You are setting the text within the animation block so after the delay is over, the animations begin which immediately changes the text as that change is not animatable. To do what you want, change the text in the completion block as follows:
[UIView animateWithDuration:0.5
delay:4.0
options: UIViewAnimationOptionTransitionCrossDissolve
animations:^{ // anything animatable }
completion:^(BOOL finished) {
currentShapeNameLabel.text = @"New Text" ;}];
You can eliminate the delay if you want the animation to start immediately. If you want the text change to happen 4 secs after the animation completes add that delay in the completion block either with dispatch_after()
or performSelector:withDelay:
.
In my case, the problem was that earlier in the code I was calling UIView
's snapshotViewAfterScreenUpdates
with a value true
. After changing that to false
it worked fine.