instacart/Nantes

Support for NSTextAttachment

ngoleo opened this issue · 0 comments

Is your feature request related to a problem? Please describe.
It would be nice if we could support rendering an NSTextAttachment inside an attributed string, typically used to render icons inline with a label's text.

Describe the solution you'd like
When attributedText contains an NSTextAttachment, render the attachment image inline with the rest of the text, similar to how UILabel renders these.

Examples of usage:

Technical complexity

  • Rendering NSTextAttachment's in UILabel is likely managed by TextKit's NSLayoutManager, which we're bypassing and substituting with our own CoreText drawing in NantesLabel's implementation. Making it work with CoreText might not be practical/possible.

Describe alternatives you've considered

  • Just use UILabel itself, but you lose out on the benefits of NantesLabel. :D
  • Explore not overriding func drawText(in rect: CGRect) and let UILabel do the rendering. Not sure if we can do this and still support the current features.

Additional context