I searched the internet for hours and I couldnt come up with a good solution.
I try to scroll text on my UIView from left to right and vice versa. I dont want to use CoreAnimations as I need to be in control over the animation.
The movement follows a sinus curve, 0 to pi or 0->1->0.
What is the best way to implement that custom animation?
What I came up with after some research, is a recoursive algorithm that calls it self and goes through the loop, until done.
- (void) scrollText:(id)sender timeConstant:(float) _timeconstant timeOffset:(NSDate*) _timeoffset direction:(int)_direction
{
float p = [[NSDate date] timeIntervalSinceDate:_timeoffset] / _timeconstant * _direction;
float ps = sinf( p * M_PI);
CGSize txtsize = [msg_text sizeWithFont:font];
float offset = txtsize.width / 2;
float screenwidth = self.view.frame.size.width;
float screenheight= self.view.frame.size.height;
int virtualwidth = txtsize.width;
[ivText setFrame:CGRectMake(screenwidth/2 - offset + (virtualwidth / 2 * ps), 100, txtsize.width, txtsize.height)];
//redraw
[[self view] setNeedsDisplay];
//keep going
if (ps * _direction > 0) [self scrollText:self timeConstant:_timeconstant timeOffset:_timeoffset direction:_direction];
}
The problem now is, that the view wont update :( and Im not sure if this is the best approach for this kind of animation.