@@ -168,6 +168,19 @@ - (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText
168168 range: NSMakeRange (0 , attributedText.length)];
169169}
170170
171+ // iOS 13 attributed string attachments have placeholder images
172+ // https://github.com/facebook/react-native/pull/26653/files
173+ static UIImage *emptyImg = NULL ;
174+ - (UIImage*)getEmptyImg
175+ {
176+ if (emptyImg == NULL ) {
177+ UIGraphicsBeginImageContextWithOptions (CGSizeMake (1 , 1 ), NO , 0 );
178+ emptyImg = UIGraphicsGetImageFromCurrentImageContext ();
179+ UIGraphicsEndImageContext ();
180+ }
181+ return emptyImg;
182+ }
183+
171184- (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize : (CGSize)size
172185{
173186 NSMutableAttributedString *attributedText =
@@ -188,6 +201,7 @@ - (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize:(CGSize
188201 maximumSize: size];
189202 NSTextAttachment *attachment = [NSTextAttachment new ];
190203 attachment.bounds = (CGRect){CGPointZero, fittingSize};
204+ [attachment setImage: [self getEmptyImg ]];
191205 [attributedText addAttribute: NSAttachmentAttributeName value: attachment range: range];
192206 }
193207 ];
@@ -297,7 +311,7 @@ - (void)layoutSubviewsWithContext:(RCTLayoutContext)layoutContext
297311 RCTRoundPixelValue (attachmentSize.width ),
298312 RCTRoundPixelValue (attachmentSize.height )
299313 }};
300-
314+
301315 NSRange truncatedGlyphRange = [layoutManager truncatedGlyphRangeInLineFragmentForGlyphAtIndex: range.location];
302316 BOOL viewIsTruncated = NSIntersectionRange (range, truncatedGlyphRange).length != 0 ;
303317
0 commit comments