Post not yet marked as solved
Post marked as unsolved with 0 replies, 513 views
Just upgraded to Xcode 12.4 and now I cannot invert colors on images in the simulator. Works on physical devices but not in the simulator.
Problem is I NEED the simulator for required screenshots for devices I don't own.
Do other have this same problem of it not working?
(UIImage *)getImage:(NSString *)name background:(NSString *)background scale:(int)scale {
NSLog(@"getImage: %@", name);
UIImage *image = [UIImage imageNamed:name];
float w = image.size.width / scale;
float h = image.size.height / scale;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(w, h), NO, 0);
[image drawInRect:CGRectMake(0, 0, w, h)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
image = newImage;
if (background == nil) {return image;}
// if background is light, no need to convert button color to white
if (![Tools isColorDark:background]) {return image;}
// convert image from black to white
CIImage *coreImage = [CIImage imageWithCGImage:image.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIColorInvert"];
[filter setValue:coreImage forKey:kCIInputImageKey];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
return [UIImage imageWithCIImage:result scale:image.scale orientation:image.imageOrientation];
}