@@ -168,6 +168,19 @@ - (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText
168
168
range: NSMakeRange (0 , attributedText.length)];
169
169
}
170
170
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
+
171
184
- (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize : (CGSize)size
172
185
{
173
186
NSMutableAttributedString *attributedText =
@@ -188,6 +201,7 @@ - (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize:(CGSize
188
201
maximumSize: size];
189
202
NSTextAttachment *attachment = [NSTextAttachment new ];
190
203
attachment.bounds = (CGRect){CGPointZero, fittingSize};
204
+ [attachment setImage: [self getEmptyImg ]];
191
205
[attributedText addAttribute: NSAttachmentAttributeName value: attachment range: range];
192
206
}
193
207
];
@@ -297,7 +311,7 @@ - (void)layoutSubviewsWithContext:(RCTLayoutContext)layoutContext
297
311
RCTRoundPixelValue (attachmentSize.width ),
298
312
RCTRoundPixelValue (attachmentSize.height )
299
313
}};
300
-
314
+
301
315
NSRange truncatedGlyphRange = [layoutManager truncatedGlyphRangeInLineFragmentForGlyphAtIndex: range.location];
302
316
BOOL viewIsTruncated = NSIntersectionRange (range, truncatedGlyphRange).length != 0 ;
303
317
0 commit comments