简体   繁体   中英

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!

您可以使用imageView.bounds创建一个rect,然后尝试不确定但希望它能正常工作吗

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM