Nicholas Allio Nicholas Allio - 1 year ago 137
Swift Question

Add multiple images in UITextView long text

I would like to know how to build a

with images inserted in the text. I know I can add them as attachment but I would like to introduce a challenge on top of that: I would like to add padding at the text but not at the images, like shown in the picture. (Do not look at the initial image of the capital letter)

How can I do?

enter image description here

Answer Source

I solved the problem using a UIWebView in place of the UITextView. I render a local HTML page which is easier to customize in these cases.

For a better result I've set scalePageToFit = true and disabled all the other options of the UIWebView. Moreover, in order to disable the zooming by the user, I implemented the UIScrollViewDelegate method viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? to simply returning nil value to a better user experience.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download