是否可以减慢scrollRangeToVisible的速度?
我正在创建一个使用 AVAudioPlayer 播放歌曲的应用程序,并且我设置了一个 textView 在播放歌曲时滚动浏览歌曲的歌词,但我发现的所有滚动选项都会滚动到 textView 大小的底部内容几乎是即时的。有没有办法控制速度?或者,如果我必须在歌曲的持续时间内加载多个scrollRangeToVisible调用,有没有办法让它平滑地动画化,而不是从scrollRangeToVisible调用中从一个点“跳跃”到另一个点?这是我正在使用的代码
scrollPoint.y= [textView.text length];
[textView setContentOffset:scrollPoint animated:YES];
// also tried this
//[textView scrollRangeToVisible:NSMakeRange([textView.text length], 0)];
I'm creating an app that will play a song with AVAudioPlayer, and I setup a textView to scroll through the lyrics of the song as it's playing, but all the scrolling options I've found scroll to the bottom of the size of the textView's contents almost instantaneously. Is there a way to control the speed? Or if I have to load multiple scrollRangeToVisible calls through the duration of the song, is there a way to make it animate smoothly instead of "jumping" from point to point on from the scrollRangeToVisible calls? This is the code I'm using
scrollPoint.y= [textView.text length];
[textView setContentOffset:scrollPoint animated:YES];
// also tried this
//[textView scrollRangeToVisible:NSMakeRange([textView.text length], 0)];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将代码放在 UIView 动画块内设置内容偏移量,则可以根据需要设置持续时间。例如,
不要使用
-[UIScrollView setContentOffset:animated:]
因为这会覆盖块的动画持续时间If you put your code to set the content offset inside a UIView animation block, you can set the duration as necessary. e.g.
Don't use
-[UIScrollView setContentOffset:animated:]
as this will override your block's animation duration