2023-10-28 04:46:10 +08:00
|
|
|
|
//
|
|
|
|
|
// YYTextAsyncLayer+PITextAsyncLayer.m
|
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by duoban on 2023/10/28.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "YYTextAsyncLayer+PITextAsyncLayer.h"
|
|
|
|
|
|
|
|
|
|
@implementation YYTextAsyncLayer (PITextAsyncLayer)
|
|
|
|
|
///iOS17bug,如果不把方法替换会闪退
|
|
|
|
|
+(void)load {
|
2023-10-28 20:36:20 +08:00
|
|
|
|
Method displayMethod = class_getInstanceMethod(self, @selector(display));
|
|
|
|
|
Method swizzingMethod = class_getInstanceMethod(self, @selector(swizzing_display));
|
|
|
|
|
method_exchangeImplementations(displayMethod, swizzingMethod);
|
2023-10-28 04:46:10 +08:00
|
|
|
|
}
|
|
|
|
|
-(void)swizzing_display{
|
|
|
|
|
//通过变量名称获取类中的实例成员变量
|
2023-10-28 20:36:20 +08:00
|
|
|
|
if (self.bounds.size.width <= 0 || self.bounds.size.height <= 0) {
|
2023-10-28 04:46:10 +08:00
|
|
|
|
self.contents = nil;
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
[self swizzing_display];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@end
|