I read the entire existing solution in stackoverflow for similar problems, but without it.
Malfunction in UITextView when trying to scroll text to position with animation. The upper part of the text disappears when scrolling with animation, but if the font size is 15pt everything is fine, but if it is about 50pt, then something will go wrong.
You can see it on the video https://www.youtube.com/watch?v=EvIur672Q5k
I am also trying to create my own method to animate scrolling with a loop and offset the offset of each loop by 0.5pt, but this uses the processor too much, and I cannot control the animation time because the processor is overloaded.
https://www.youtube.com/watch?v=Kw5hx3YAdMw
I am also trying to create a UITextView programmatically with the same result.
I am trying to split the animation into parts with a linear curve, but this is such an ugly shake animation.
- (IBAction) start{
_textView.scrollEnabled = NO;
_textView.scrollEnabled = YES;
UITextPosition *Pos2 = [_textView positionFromPosition: _textView.beginningOfDocument offset: 501];
UITextPosition *Pos1 = [_textView positionFromPosition: _textView.beginningOfDocument offset: 500];
UITextRange *range = [_textView textRangeFromPosition:Pos1 toPosition:Pos2];
CGRect result1 = [_textView firstRectForRange:(UITextRange *)range];
result1.origin.x=0;
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionCurveLinear animations:^{
_textView.contentOffset = result1.origin;
} completion:^(BOOL finished){
}];
}
source
share