react-native-vector-icons
react-native-vector-icons copied to clipboard
Crashes the app, as IOS has deprecated UIGraphicsBeginImageContextWithOptions from IOS 17.
Environment
[iOS] react-native-vector-icons: 10.0.2
Description
Crashes the app, as IOS has deprecated UIGraphicsBeginImageContextWithOptions from IOS 17.
Patch
diff --git a/RNVectorIconsManager/RNVectorIconsManager.mm b/RNVectorIconsManager/RNVectorIconsManager.mm
index 73b94c4..99bd769 100644
--- a/RNVectorIconsManager/RNVectorIconsManager.mm
+++ b/RNVectorIconsManager/RNVectorIconsManager.mm
@@ -62,15 +62,15 @@ - (BOOL)createAndSaveGlyphImage:(NSString *)glyph withFont:(UIFont *)font
// No cached icon exists, we need to create it and persist to disk
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:glyph attributes:@{NSFontAttributeName: font, NSForegroundColorAttributeName: color}];
-
CGSize iconSize = [attributedString size];
- UIGraphicsBeginImageContextWithOptions(iconSize, NO, 0.0);
- [attributedString drawAtPoint:CGPointMake(0, 0)];
+ UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
- UIImage *iconImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
+ UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:iconSize];
+ newImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
+ [attributedString drawAtPoint:CGPointMake(0, 0)];
+ }];
- NSData *imageData = UIImagePNGRepresentation(iconImage);
+ NSData *imageData = UIImagePNGRepresentation(newImage);
return [imageData writeToFile:filePath atomically:YES];
}