I have a text field to which I load the content using JSON. How would I also add images to it? For example if I were to use the image link for it.
This is the way I want it. I want to be able to display pictures in-between texts.
I have a text field to which I load the content using JSON. How would I also add images to it? For example if I were to use the image link for it.
This is the way I want it. I want to be able to display pictures in-between texts.
You must create a json parser and create a NSTextAttachment
for each image:
let textAttachment = NSTextAttachment()
textAttachment.image = yourImage
let attrStringWithImage = NSAttributedString.init(attachment: textAttachment)
attributedString.replaceCharactersInRange(NSMakeRange(6, 1), withAttributedString: attrStringWithImage)
textView.attributedText = attributedString