开发者

Is it possible to slow down scrollRangeToVisible?

开发者 https://www.devze.com 2023-04-04 11:39 出处:网络
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

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)];


If you put your code to set the content offset inside a UIView animation block, you can set the duration as necessary. e.g.

[UIView animateWithDuration: <duration>
                 animations:^(void) {
                     self.textView.contentOffset = <offset>;
                 }];

Don't use -[UIScrollView setContentOffset:animated:] as this will override your block's animation duration

0

精彩评论

暂无评论...
验证码 换一张
取 消