2

Is there a way to insert text inputs inline inside a block of text? I need to allow users to input some data inline within text. I thought that I would be able to use NSMutableString with attachments, but it seems to support only UIImage as attachments.

This is an example of what I'm trying to achieve:

enter image description here

Thanks!

koss
  • 874
  • 1
  • 10
  • 22
  • 2
    You should take a closer look to _CoreText_ (https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html) which gives you a very fine grained access to text layout. But anyway, this is a difficult task. You may create a HTML-Page with `input` fields and display it in a `WKWebView`, which should be much easier to implement. – clemens Nov 15 '16 at 11:38
  • you can try something like this here: http://stackoverflow.com/questions/13216135/wrapping-text-in-a-uitextview-around-a-uiimage-without-coretext – zombie Nov 15 '16 at 12:08
  • @macmoonshine Thank you for your suggestions! I tried the simpler approach with WKWebView and it worked out just fine for my case. If you copy your comment over to answer area, I'll be happy to mark it as the correct one – koss Nov 19 '16 at 14:02

2 Answers2

1

You should take a closer look to CoreText which gives you a very fine grained access to text layout. But anyway, this is a difficult task. You may create a HTML-Page with input fields and display it in a WKWebView, which should be much easier to implement.

clemens
  • 16,716
  • 11
  • 50
  • 65
0

If the text is static, create a custom UIView class, and position the UILabel and UITextView controls. This is the only possible approach.

If the text is dynamic, you can make use of Auto-layout concept along with the above approach.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102