how to animate the uilabel view which has some text , in obj c
in my app i am planing 开发者_如何学Pythonto add the animation for the textLabels, which should come from left side of the screen
i have used following code but its crashing
(void)animateLoop {
UILabel *mylab;
mylab.text=@"SAAAAdiiiii";
mylab.frame = CGRectMake(-mylab.bounds.size.width, 100, mylab.bounds.size.width, mylab.bounds.size.height);
[UIView beginAnimations:@"timesquare" context:nil];
[UIView setAnimationDuration:5];
[UIView setAnimationRepeatAutoreverses:(YES)];
[UIView setAnimationRepeatCount:10];
mylab.frame = CGRectMake(480, 100, mylab.bounds.size.width, mylab.bounds.size.height);
[UIView commitAnimations];
}
n i called this in the viewDidload
but it was crashing at this line mylab.text=@"SAAAAdiiiii"; crashLog:invalidargument
can any one tell me how can i animate the uilabel
thanx in advance
You need to alloced the UILabel . means first create the memory for you label ...
UILabel *mylab = [[UILabel alloc] initWithFrame:CGRectMake(x,y,width,height)];
mylab.text=@"SAAAAdiiiii";
Suggest you to have UILabel *mylab;
as iVar
, because it has to be released
.
You have to allocate and init your UILabel first..
instead of UILabel *mylab;
try UILabel *mylab = [[UILabel alloc] init];
You also have to release it somewhere and you have to add the label to your view (something like [self.view addSubview:mylab];
).
精彩评论