CGPoint cursorPosition
= [textView caretRectForPosition:textView.selectedTextRange.start].origin;
NSLog(@"x: %f, y: %f",cursorPosition.x, cursorPosition.y);
另外要記得確認selectTextRange不是nil
參考網址:
Cursor position in a UITextView
Pixel-Position of Cursor in UITextView