如何从长动画移动字符串中获取当前可见子字符串
在从右到左的长动画移动字符串中,我想获得实际可见的子字符串。是否可以在动画过程中获得它?
我必须保留横幅的两个功能:
- 平滑移动
- 在屏幕上的某个点获取子字符串(几个字符)
它是一行中的长字符串。
我使用这个动画:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
...
[UIView commitAnimations];
我尝试过:
CGPoint currentPosition = [[self.autoScrollText.layerpresentationLayer]position];
但没有成功...
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.autoScrollText.layer presentationLayer] position];
but unsuccessfully...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的文本采用标准宽度字体(例如 Courier),您可以通过关联
UITextView
的位置、字符的宽度以及视口的 LHS 和 RHS 来完成此操作。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.另一种可能性是使用启发式。我猜你正在做许多(
i
)不同的事情,具体取决于用户单击按钮时哪个字符串“可见”。确切地说,其中哪一个最终取决于文本字符串的来源(x
位置)。不要以编程方式解决这个问题,而是自己解决(通过观察/反复试验),并根据您确定的x
范围在i
不同选项之间进行选择。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 thei
different options based on the ranges ofx
that you determine.