I'm trying to get a custom view in an attributed string to be displayed on a textView. I am able to add an image with an NSTextAttachment, but it isn't what I want. I have a custom view that supports Gif's and Animated PNGs that I'd like to display between text.
Example:
text text text [customView] text [customView] text. <- In text view, preferably in attributed string
I would love some guidance as to where I should search specifically. So far I've seen related issues...
- Subclass NSTextAttachment: How to subclass NSTextAttachment?
- Use NSTextAttachmentContainer..?
- NSTextAttachmentCell - Only OSX
- Do manipulation in the text view
First, use
NSAttributedStringorNSMutableAttributedStringto show your RichText in subviews (such as UITextView/UILabel)Then, use
NSTextAttachmentto replace your image-script in text.BTW: if you use the
YYkitfor the RichText, you cannot use theYYAttachMentStringto replaceNSAttachMentString, these are different things, theUITextView(UILabel)cannot load theYYAttachMentString. I'm looking for some way to show my gifs with theUITextView(becauseYYKitcannot load and preview netimage with a url,YYKitalways show empty which should be anetImage, cripes!)