Okay, so I choose to animate my label using block animation.
The logic is quite simple, I have a chart bar made of buttons, when the button is pressed, it create a label with no width, and then at the same method, the animation start to lengthen the label so that the words inside the label came out, and then after a brief 2.5 seconds delay, the label shrink again and removed from the superview.
The problem is :
-
The delay is working properly in OS 4.3.
The animation works as intended, it shows the label, after 2.5 it fires the next animation and closed the label. -
The delay is ignored in OS 5.0.
After the first animation complete, it didn’t wait for the delay, instead, fires the next animation blocks immediately.
Here is some of my code regarding the animation:
UILabel *lbl = [self createLabelWithText:numString frame:CGRectMake(touchPoint.x, touchPoint.y, 0, 10) bold:YES font:@"Helvetica" fontSize:10 color:[UIColor whiteColor] textAlignment:UITextAlignmentLeft andTag:987];
[lbl setBackgroundColor:[UIColor blackColor]];
[lbl setAlpha:0.5];
[self.view addSubview:lbl];
[UIView animateWithDuration:0.3 animations:^
{
[lbl setFrame:lblRect];
}completion:^(BOOL finished)
{
[UIView animateWithDuration:0.2 delay:2.5 options:UIViewAnimationOptionCurveEaseInOut animations:^
{//here the second animation delay run properly on 4.3 , but ignored at 5.0
[lbl setFrame:CGRectMake(touchPoint.x, touchPoint.y, 0, 10)];
}completion:^(BOOL finished) {
[lbl removeFromSuperview];
}];
}];
Thanks in advance for your help!
Edit : in case of any of you wondering why this person didn’t search on google or other stackoverflow questions, in fact, I did, and sadly all the posts I found doesn’t provide me with answers I needed. 🙁
okay, i’ve found the problem. it’s not exactly the blocks animation’s fault, rather it’s the error that occures because i set my animation to shrink my uilabel to width “0”. turns out in IOS 5.0 (in my project at least) because i set my label size by using constraint, when i tried to shrink the label, as soon as it reads the label aren’t suffice to show the entire text, it immediately terminate the label it self.