Reputation: 19
I'm having problems with the animation of labels and textfield. The labels just disappear and the text fields don't do anything. I don't know why, but with buttons i have no problem. Think missing something really stupid. Well here is what a i have tried for labels:
UILabel *label = (UILabel*)[self.view viewWithTag:1];
[UIView animateWithDuration:1 animations:^{label.frame = CGRectMake(0,0,1,1);}];
For text fields:
UITextField *box = (UITextField*)[self.view viewWithTag:1];
[UIView animateWithDuration:1 animations:^{box.frame = CGRectMake(0,0,1,1);}];
What i'm missing?
Upvotes: 0
Views: 1481
Reputation: 1615
CGRectMake(0,0,1,1)
is going to be a really small box. They're not disappearing, you're shoving it all into one pixel. Try something more reasonable, like CGRectMake(0,0,100,50)
and see if that works.
CGRectMake
is defined as:
CGRect CGRectMake (
CGFloat x,
CGFloat y,
CGFloat width,
CGFloat height
);
so you were setting the width and height to 1.
If you just want to move the center without resizing, try this.
[UIView animateWithDuration:1 animations:^{label.center = CGPointMake(x,y);}];
where x and y are the coordinates of the new center.
Upvotes: 2