UILabels text disappears when animating
Posted
by
Wilhelm Michaelsen
on Stack Overflow
See other posts from Stack Overflow
or by Wilhelm Michaelsen
Published on 2014-05-30T21:00:57Z
Indexed on
2014/05/30
21:26 UTC
Read the original article
Hit count: 216
objective-c
I have this code:
- (void)my_button_tapped
{
if (my_button.tag == 0)
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
my_label.frame = CGRectMake(450, 455, 200, 20);
[UIView commitAnimations];
[my_button setBackgroundImage:[UIImage imageNamed:@"check.png"] forState:UIControlStateNormal];
my_button.tag = 1;
}
else
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
my_label.frame = CGRectMake(450, 455, 0, 20);
[UIView commitAnimations];
[my_button setBackgroundImage:nil forState:UIControlStateNormal];
my_button.tag = 0;
}
}
When I tap my_button first time the label is expanded into 200px width, when I press the button again the label decreases to 0px width but immediately at button press the text disappears. What's wrong?
© Stack Overflow or respective owner