UITextView firstRectForRange not working when there's new line characters in the mix

后端 未结 1 1996
[愿得一人]
[愿得一人] 2021-01-15 12:22

I\'m using this method for converting a NSRange to a CGRect as it relates to a UITextView:

- (CGRect)frameOfTextRange:(NSRange)range inTextView:(UITextView *         


        
相关标签:
1条回答
  • 2021-01-15 13:12

    You can force self.textView to ensure the layout of textView immediately with

     [self.textView.layoutManager ensureLayoutForTextContainer:self.textView.textContainer];
    

    Placing that before your frameOfTextRange: call will gives you right rect.

    0 讨论(0)
提交回复
热议问题