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.
|
// 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)
|
// 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 {
|
- (NSView *)imageView {
|
||||||
NSImageView *imageView = imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageView"));
|
NSImageView *imageView = imageView = objc_getAssociatedObject(self, SD_SEL_SPI(imageView));
|
||||||
if (!imageView) {
|
if (!imageView) {
|
||||||
// macOS 10.14
|
// macOS 10.14
|
||||||
imageView = objc_getAssociatedObject(self, NSSelectorFromString(@"_imageSubview"));
|
imageView = objc_getAssociatedObject(self, SD_SEL_SPI(imageSubview));
|
||||||
}
|
}
|
||||||
return imageView;
|
return imageView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#import "UIImage+Metadata.h"
|
#import "UIImage+Metadata.h"
|
||||||
#import "NSImage+Compatibility.h"
|
#import "NSImage+Compatibility.h"
|
||||||
|
#import "SDInternalMacros.h"
|
||||||
#import "objc/runtime.h"
|
#import "objc/runtime.h"
|
||||||
|
|
||||||
@implementation UIImage (Metadata)
|
@implementation UIImage (Metadata)
|
||||||
|
@ -42,14 +43,14 @@
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
// SVG
|
// SVG
|
||||||
SEL SVGSelector = NSSelectorFromString(@"_CGSVGDocument");
|
SEL SVGSelector = SD_SEL_SPI(CGSVGDocument);
|
||||||
if ([self respondsToSelector:SVGSelector] && [self performSelector:SVGSelector]) {
|
if ([self respondsToSelector:SVGSelector] && [self performSelector:SVGSelector]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
|
if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
|
||||||
// PDF
|
// PDF
|
||||||
SEL PDFSelector = NSSelectorFromString(@"_CGPDFPage");
|
SEL PDFSelector = SD_SEL_SPI(CGPDFPage);
|
||||||
if ([self respondsToSelector:PDFSelector] && [self performSelector:PDFSelector]) {
|
if ([self respondsToSelector:PDFSelector] && [self performSelector:PDFSelector]) {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
#define SD_OPTIONS_CONTAINS(options, value) (((options) & (value)) == (value))
|
#define SD_OPTIONS_CONTAINS(options, value) (((options) & (value)) == (value))
|
||||||
#endif
|
#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
|
#ifndef weakify
|
||||||
#define weakify(...) \
|
#define weakify(...) \
|
||||||
sd_keywordify \
|
sd_keywordify \
|
||||||
|
|
Loading…
Reference in New Issue