-
-
Save axelrivera/7761921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UITextView (Annex) | |
@dynamic visibleTextRange; | |
- (NSRange)visibleTextRange | |
{ | |
CGRect bounds = self.bounds; | |
CGSize textSize = [self.text sizeWithFont:self.font constrainedToSize:bounds.size]; | |
UITextPosition *start = [self characterRangeAtPoint:bounds.origin].start; | |
UITextPosition *end = [self characterRangeAtPoint:CGPointMake(textSize.width, textSize.height)].end; | |
NSUInteger startPoint = [self offsetFromPosition:self.beginningOfDocument toPosition:start]; | |
NSUInteger endPoint = [self offsetFromPosition:start toPosition:end]; | |
return NSMakeRange(startPoint, endPoint); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment