Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes the app, as IOS has deprecated UIGraphicsBeginImageContextWithOptions from IOS 17. #1576

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarmineRumma
Copy link

UIGraphicsBeginImageContextWithOptions Patch

@husenLogicwind
Copy link

husenLogicwind commented Apr 29, 2024

@CarmineRumma
I tried to apply this patch and it will not work for me it give me a error
Use of undeclared identifier 'image'
Screenshot 2024-04-29 at 12 33 35 PM

@qaseemelahi
Copy link

qaseemelahi commented Apr 29, 2024

@husenLogicwind I've used following patch my build created but I'm not sure weather its accurate or not
@CarmineRumma please verify this.

diff --git a/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.m b/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.m
index 02a5f49..4ffa62f 100644
--- a/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.m
+++ b/node_modules/react-native-vector-icons/RNVectorIconsManager/RNVectorIconsManager.m
@@ -63,13 +63,13 @@ - (BOOL)createAndSaveGlyphImage:(NSString *)glyph withFont:(UIFont *)font
     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 *iconImage = UIGraphicsGetImageFromCurrentImageContext();
-    UIGraphicsEndImageContext();
-
-    NSData *imageData = UIImagePNGRepresentation(iconImage);
+    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
+    UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
+    UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:iconSize];
+    newImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
+      [attributedString drawAtPoint:CGPointMake(0, 0)];
+    }];
+    NSData *imageData = UIImagePNGRepresentation(newImage);
     return [imageData writeToFile:filePath atomically:YES];
   }
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants