【问题标题】:How to control the speed of a auto scroll in uitextview如何控制uitextview中自动滚动的速度
【发布时间】:2012-03-31 01:20:47
【问题描述】:

如何控制 UITextView 中滚动文本的速度。我是iOS新手,无法弄清楚这一点。下面是我调用的开始滚动的方法。

[InputTextField scrollRangeToVisible:NSMakeRange([InputTextField.text length]-1, -1)];

我希望能够改变滚动的速度。 谢谢

【问题讨论】:

    标签: ios uiscrollview nstimer


    【解决方案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){                                                  
    }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-08
      • 1970-01-01
      • 2017-03-12
      • 1970-01-01
      • 2017-07-09
      相关资源
      最近更新 更多