0

Does anyone know how get the NSTextAttachment image's position centre in UITextView?

I'm working on an app that allow user to input text and image in a UITextView, and when user click on an image, it will show the image viewer for all images. This is easy, and I have get this done.

Now, I need to create a custom transition from UITextView (in a UIViewController) to the image viewer, I'm struggling to find each image's centre in the UITextView so I can create a snapshot for the custom transitioning.

The custom transitioning is basically the same as iOS "Note" app, when tap on an image, then create an snapshot, move it the right position.

I appreciate any help or idea to solve this problem.

mmk
  • 207
  • 4
  • 7
  • `UITextView` has a `NSTextStorage`/`NSLayoutManager/`NSTextManager` properties (or "sub properties"). This question could be a lead: https://stackoverflow.com/questions/19417776/how-do-i-locate-the-cgrect-for-a-substring-of-text-in-a-uilabel – Larme Jun 28 '18 at 08:08
  • The problem is I can get the bound of the attachment's size, however, I need the (x, y) coordination as well, so I can find the exact position and calculate the centre of the attachment in UITextView. Thanks in advance to @Larme for the great hint. – mmk Jun 28 '18 at 13:05

0 Answers0