UITextView环绕UIImage吗

UITextView环绕UIImage吗

本文介绍了iPhone:UITextView环绕UIImage吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得一个UITextView来将其文本环绕在UIImage中,如该图像所示?

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

图像尺寸不一定是以前已知的.

The image size is not necessarily previously known.

推荐答案

IOS 7及更高版本:

IOS 7 and above:

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

迅捷(归功于Bart van Kuik):

Swift (credit to Bart van Kuik):

let exclusionPath = UIBezierPath(rect: CGRectMake(0, 0, 100, 100))
self.textView.textContainer.exclusionPaths = [exclusionPath]

这篇关于iPhone:UITextView环绕UIImage吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 00:06