I studied smcalloutview in the morning and found that the author directly put the image as a string in the source code file. The advantage of this is that the resource files that the program depends on are directly placed together with the code. You only need to copy the source code to use them. It's easy to think about it: first convert the image resource into a base64 string, and then declare the string as a constant. When using nsdata, convert it to uiimage:
+ (UIImage *)embeddedImageNamed:(NSString *)name { if ([UIScreen mainScreen].scale == 2) name = [name stringByAppendingString:@"$2x"]; SEL selector = NSSelectorFromString(name); if (![(id)self respondsToSelector:selector]) { NSLog(@"Could not find an embedded image. Ensure that you've added a category method to UIImage named +%@", name); return nil; } // We need to hush the compiler here - but we know what we're doing! #pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" NSString *base64String = [(id)self performSelector:selector]; #pragma clang diagnostic pop UIImage *rawImage = [UIImage imageWithData:[self dataWithBase64EncodedString:base64String]]; return [UIImage imageWithCGImage:rawImage.CGImage scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp];}
In addition, I suspect there is another reason why the author is so hard to explain. The image resources of smcalloutview are actually uicalloutview resources extracted from IOS using the uikit-artwork-Extractor. The latter is a private API and is not open. Can I use base64 to perform mounting detection? After all, using this method to process image resources means that the system's image cache cannot be used.