Wrapping Text in a UITextView Around a UIImage WIT

2019-01-07 07:33发布

Is there a way to wrap text from a UITextView around a UIImage without using CoreText?

I have been playing around with attributed strings without much luck, and CoreText just seems extremely complicated so I would rather stay out of it.

2条回答
Animai°情兽
2楼-- · 2019-01-07 08:19

The short answer is you can't without CoreText pre iOS 7.

I've been struggling with this my self a while ago and the was very helpfull to me. http://robnapier.net/blog/wrapping-text-around-shape-with-coretext-540 It is CoreText though.

查看更多
唯我独甜
3楼-- · 2019-01-07 08:21

This seems to do the trick:

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

Works only from iOS 7 and up.

查看更多
登录 后发表回答