YYTextAsyncLayer+Hook.m 722 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // YYTextAsyncLayer+Hook.m
  3. // sansanMassage_Consumer
  4. //
  5. // Created by YoMi on 2023/12/14.
  6. //
  7. #import "YYTextAsyncLayer+Hook.h"
  8. @implementation YYTextAsyncLayer (Hook)
  9. + (void)load {
  10. static dispatch_once_t onceToken;
  11. dispatch_once(&onceToken, ^{
  12. Method a = class_getInstanceMethod(self, @selector(display));
  13. Method b = class_getInstanceMethod(self, @selector(swizzing_display));
  14. method_exchangeImplementations(a, b);
  15. });
  16. }
  17. - (void)swizzing_display{
  18. //通过变量名称获取类中的实例成员变量
  19. if (self.bounds.size.width<=0 || self.bounds.size.height<=0) {
  20. self.contents = nil;
  21. return;
  22. } else {
  23. [self swizzing_display];
  24. }
  25. }
  26. @end