Is it possible to create UITextRange manually for first character?

3.8k Views Asked by At

Is it possible to instantiate UITextRange and for first character of UITextField? i need to access to rect of UITextField 's first character, can anyone help me?

Thanks in advance

1

There are 1 best solutions below

2
On BEST ANSWER

You can manually create a UITextRange with the methods provided by UITextInput:

UITextPosition *firstCharacterPosition = [textField beginningOfDocument];
UITextPosition *secondCharacterPosition = [textField positionFromPosition:firstCharacterPosition offset:1];
UITextRange *firstCharacterRange = [textField textRangeFromPosition:firstCharacterPosition toPosition:secondCharacterPosition];
NSString *firstCharacter = [textField textInRange:firstCharacterRange];