如何控制 UITextView 中滚动文本的速度。我是 iOS 的新手,无法弄清楚这一点。下面是我调用以启动滚动的方法。
[InputTextField scrollRangeToVisible:NSMakeRange([InputTextField.text length]-1, -1)];
我希望能够改变滚动的速度。 谢谢
最佳答案
你不能改变 scrollRangeToVisible
的动画速度,但你可以使用 contentOffset
确保你使用的是 UITextView,这不适用于 UITextField
uint offset1=-1;
uint offset2=0;
UITextPosition *Pos2 = [_textView positionFromPosition: _textView.endOfDocument offset: offset2];
UITextPosition *Pos1 = [_textView positionFromPosition: _textView.endOfDocument offset: offset1];
UITextRange *range = [_textView textRangeFromPosition:Pos1 toPosition:Pos2];
CGRect result1 = [_textView firstRectForRange:(UITextRange *)range];
result1.origin.x=0;//reset x position to zero
[UIView animateWithDuration:3.0 delay:0.0 options:UIViewAnimationOptionCurveLinear
animations:^{
_textView.contentOffset = result1.origin;
}
completion:^(BOOL finished){
}];
关于ios - 如何控制uitextview中自动滚动的速度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9952188/