是否可以实例化 UITextRange
和 UITextField
的第一个字符?
我需要访问 UITextField
的第一个字符的 rect,有人可以帮我吗?
提前致谢
最佳答案
您可以使用 UITextInput
提供的方法手动创建一个 UITextRange
:
UITextPosition *firstCharacterPosition = [textField beginningOfDocument];
UITextPosition *secondCharacterPosition = [textField positionFromPosition:firstCharacterPosition offset:1];
UITextRange *firstCharacterRange = [textField textRangeFromPosition:firstCharacterPosition toPosition:secondCharacterPosition];
NSString *firstCharacter = [textField textInRange:firstCharacterRange];
关于ios - 是否可以为第一个字符手动创建 UITextRange?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22348076/