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
Add View with background colour.
UIView *animatedLblView = [[UIView alloc]initWithFrame:CGRectMake(0, 75, self.view.frame.size.width, 30)];
animatedLblView.backgroundColor = [UIColor colorWithRed:0.00 green:0.34 blue:0.61 alpha:1.0];
[self.view addSubview:animatedLblView];
//Our animated component(UIButton)
_animatingButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width+100, 30)];
[_animatingButton setTitle:@"Upload documents, please contact 1234567890" forState:UIControlStateNormal];
[animatedLblView addSubview:_animatingButton];
//Timer
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(LabelAnimation)
userInfo:nil
repeats:nil];
-(void)LabelAnimation {
//Set animation
[UIView animateWithDuration:10.0f delay:0.0f options:UIViewAnimationOptionTransitionNone animations:^{
_animatingButton.frame = CGRectMake(-(self.view.frame.size.width+100), 0, self.view.frame.size.width+100, 30);
} completion:^(BOOL finished) {
_animatingButton.frame = CGRectMake(self.view.frame.size.width, 0, 0, 30);
// Call the same function
[self LabelAnimation];
}];
}