how to get current visible substring from long animated-moving string
In a long animated-moving string from right to left, I want to get actually visible substring. Is it possible to get it in an animation process?
I must keep two features of the banner:
- smooth moving
- get substring (few characters) in some point on the screen
It is long string in one line.
I use this animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
...
[UIView commitAnimations];
I tried with:
CGPoint currentPosition = [[self.a开发者_开发问答utoScrollText.layer presentationLayer] position];
but unsuccessfully...
If your text is in a standard width font, like Courier, you could do this by relating the position of your UITextView
, the width of your characters, and the LHS and RHS of your viewport.
Another possibility is to use a heuristic. I guess you are doing a number (i
) of different things depending on which string is "visible" when the user clicks a button. Precisely which of these things ultimately depends on the origin (x
position) of your text string. Instead of working this out programatically, work it out yourself (through observation/trial and error) and select between the i
different options based on the ranges of x
that you determine.
精彩评论