Added macros to expand SPI symbol to Selector, which can make it easy to distinguish and maintain in the future
This commit is contained in:
parent
4d354c4acd
commit
4acd81177b
|
@ -470,10 +470,10 @@
|
|||
// NSImageView use a subview. We need this subview's layer for actual rendering.
|
||||
// Why using this design may because of properties like `imageAlignment` and `imageScaling`, which it's not available for UIImageView.contentMode (it's impossible to align left and keep aspect ratio at the same time)
|
||||
- (NSView *)imageView {
|
||||
NSImageView *imageView = imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageView"));
|
||||
NSImageView *imageView = imageView = objc_getAssociatedObject(self, SD_SEL_SPI(imageView));
|
||||
if (!imageView) {
|
||||
// macOS 10.14
|
||||
imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageSubview"));
|
||||
imageView = objc_getAssociatedObject(self, SD_SEL_SPI(imageSubview));
|
||||
}
|
||||
return imageView;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#import "UIImage+Metadata.h"
|
||||
#import "NSImage+Compatibility.h"
|
||||
#import "SDInternalMacros.h"
|
||||
#import "objc/runtime.h"
|
||||
|
||||
@implementation UIImage (Metadata)
|
||||
|
@ -42,14 +43,14 @@
|
|||
return YES;
|
||||
}
|
||||
// SVG
|
||||
SEL SVGSelector = NSSelectorFromString(@"_CGSVGDocument");
|
||||
SEL SVGSelector = SD_SEL_SPI(CGSVGDocument);
|
||||
if ([self respondsToSelector:SVGSelector] && [self performSelector:SVGSelector]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
|
||||
// PDF
|
||||
SEL PDFSelector = NSSelectorFromString(@"_CGPDFPage");
|
||||
SEL PDFSelector = SD_SEL_SPI(CGPDFPage);
|
||||
if ([self respondsToSelector:PDFSelector] && [self performSelector:PDFSelector]) {
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,18 @@
|
|||
#define SD_OPTIONS_CONTAINS(options, value) (((options) & (value)) == (value))
|
||||
#endif
|
||||
|
||||
#ifndef SD_CSTRING
|
||||
#define SD_CSTRING(str) #str
|
||||
#endif
|
||||
|
||||
#ifndef SD_NSSTRING
|
||||
#define SD_NSSTRING(str) @(SD_CSTRING(str))
|
||||
#endif
|
||||
|
||||
#ifndef SD_SEL_SPI
|
||||
#define SD_SEL_SPI(name) NSSelectorFromString([NSString stringWithFormat:@"_%@", SD_NSSTRING(name)])
|
||||
#endif
|
||||
|
||||
#ifndef weakify
|
||||
#define weakify(...) \
|
||||
sd_keywordify \
|
||||
|
|
Loading…
Reference in New Issue