Hayden Kreuter
Hayden Kreuter

Reputation: 31

UItextview word wrapping with exclusion paths (swift)

I am working on an application that allows the user to add an image and move it around in a UITextView. The text flows around the image using exclusionPaths, but the words will break if there is not enough room on the remainder of the line instead of moving to the next line.

This is what I'm using to add the image and create the exclusionPaths for the text container

textView.addSubview(imageview)
let imagePath = UIBezierPath(rect: imageview.frame)
textView.textContainer.exclusionPaths = imagePath

This is what is happening, notice how the words will break up to the right of the image

This is what I want to happen. The words should move to the next line if there is not enough room on the current line

Thank you for any help with this!

Upvotes: 2

Views: 1663

Answers (1)

Ashish
Ashish

Reputation: 214

Can you create a rect using imageView.bounds and then give a try not sure but hoping for it to work

Upvotes: 0

Related Questions