Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: UITextView wrap around UIImage?

How do I get a UITextView to wrap its text around a UIImage like in this image? alt text

The image size is not necessarily previously known.

like image 857
Mike C Avatar asked Dec 07 '10 19:12

Mike C


1 Answers

IOS 7 and above:

UIBezierPath * imgRect = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 100, 100)];
self.textView.textContainer.exclusionPaths = @[imgRect];

Swift (credit to Bart van Kuik):

let exclusionPath = UIBezierPath(rect: CGRectMake(0, 0, 100, 100))
self.textView.textContainer.exclusionPaths = [exclusionPath]
like image 87
Gil Margolin Avatar answered Nov 11 '22 07:11

Gil Margolin