vladasha vladasha - 6 months ago 88
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?



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]