2

How do I wrap text around an image in a tableview. Below is a sample of a tableview with image and text, I would like to have the text wrap to the side and below the image.

enter image description here

al over
  • 91
  • 1
  • 5

1 Answers1

9

Use UITextView for this,

cell.layoutIfNeeded()
let imageFrame = UIBezierPath(rect: cell.imageView.frame)
cell.textView.textContainer.exclusionPaths = [imageFrame]
Aju Antony
  • 639
  • 6
  • 13
  • 2
    This is correct, however it should be noted that you may first need to convert the frames because their coordinate spaces could be different. How to do so is demonstrated in this answer: https://stackoverflow.com/a/45280820/4442731 – TomQDRS Sep 23 '20 at 09:38