From c59b60385f0d8e369a991fb1c638fdc426a746f9 Mon Sep 17 00:00:00 2001 From: Abraham Przewodnik Date: Mon, 30 Sep 2019 14:32:40 +0200 Subject: [PATCH] iOS: Possible fix for #26577 See https://github.com/facebook/react-native/issues/26577 for the idea behind this change --- Libraries/Text/Text/RCTTextShadowView.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Libraries/Text/Text/RCTTextShadowView.m b/Libraries/Text/Text/RCTTextShadowView.m index 1543bca7a6cd18..55327d6c57e5b3 100644 --- a/Libraries/Text/Text/RCTTextShadowView.m +++ b/Libraries/Text/Text/RCTTextShadowView.m @@ -175,6 +175,17 @@ - (void)postprocessAttributedText:(NSMutableAttributedString *)attributedText range:NSMakeRange(0, attributedText.length)]; } +static UIImage *emptyImg = NULL; +- (UIImage*)getEmptyImg +{ + if (emptyImg == NULL) { + UIGraphicsBeginImageContextWithOptions(CGSizeMake(1, 1), NO, 0); + emptyImg = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + } + return emptyImg; +} + - (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize:(CGSize)size { NSMutableAttributedString *attributedText = @@ -195,6 +206,7 @@ - (NSAttributedString *)attributedTextWithMeasuredAttachmentsThatFitSize:(CGSize maximumSize:size]; NSTextAttachment *attachment = [NSTextAttachment new]; attachment.bounds = (CGRect){CGPointZero, fittingSize}; + [attachment setImage:[self getEmptyImg]]; [attributedText addAttribute:NSAttachmentAttributeName value:attachment range:range]; } ];