Wrapping Text in a UITextView Around a UIImage WITHOUT CoreText

前端 未结 3 1997
旧时难觅i
旧时难觅i 2020-11-29 23:15

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

I have been playing around with attrib

相关标签:
3条回答
  • 2020-11-29 23:32

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

    I've been struggling with this myself a while ago and this post was very helpful to me.

    It is CoreText though.

    0 讨论(0)
  • 2020-11-29 23:48

    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.

    0 讨论(0)
  • 2020-11-29 23:56

    In Swift 4:

    self.textView.textContainer.exclusionPaths = [UIBezierPath(rect: imageView.frame)]
    
    0 讨论(0)
提交回复
热议问题