vladasha vladasha - 1 year ago 121
iOS Question

Break text that covers other views

Is it possible to break the text automatically, so the text isn't covering it, like the example below, in UITextview?


Answer Source

Add CoreText Framework

import CoreText

Add the below code after adding the imageView to UITextView,

var exclusionPath = UIBezierPath(rect: CGRect(x: imageView.frame.orgin.x, y: imageView.frame.orgin.y, width: imageView.frame.size.width, height: imageView.frame.size.height))
textView.textContainer.exclusionPaths = [exclusionPath]