I want to show some text in my app like moving text (Scrolling with animation from right to left). How to do this programmatically?
I took UIViewcontroller
. I am developing AVAudioplayer
. so in the top side of UIViewController
the text will move from right to left.
First of all you take a label in your view and set its frame out of view as following.
- (void)viewDidLoad
{
[super viewDidLoad];
la = [[UILabel alloc]initWithFrame:CGRectMake(320, 100, 200, 60)];
la.text = @"This is my music line";
[self.view addSubview:la];
[NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(LabelAnimation)
userInfo:nil
repeats:YES];
}
Now that label give animation as below method called in ViewDidLoad
-(void)LabelAnimation
{
[UIView animateWithDuration:3.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
la.frame = CGRectMake(-320, 100, 200, 60);
} completion:^(BOOL finished)
{
la.frame = CGRectMake(320, 100, 200, 60);
}];
}
output is below.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With