Skip to content

Commit 990a35e

Browse files
[ios] fix a crash bug on ios 17.x and xcode 15.x
ref: DylanVann#1019
1 parent 9ab80fc commit 990a35e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

ios/FastImage/FFFastImageView.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ - (void) setImageColor: (UIColor*)imageColor {
7373

7474
- (UIImage*) makeImage: (UIImage*)image withTint: (UIColor*)color {
7575
UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
76-
UIGraphicsBeginImageContextWithOptions(image.size, NO, newImage.scale);
77-
[color set];
78-
[newImage drawInRect: CGRectMake(0, 0, image.size.width, newImage.size.height)];
79-
newImage = UIGraphicsGetImageFromCurrentImageContext();
80-
UIGraphicsEndImageContext();
76+
UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat defaultFormat];
77+
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:image.size format:format];
78+
79+
UIImage *resultImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
80+
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
81+
[color set];
82+
[newImage drawInRect:rect];
83+
}];
8184
return newImage;
8285
}
8386

0 commit comments

Comments
 (0)