UIBlurEffect+LookinServer.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // UIBlurEffect+LookinServer.m
  3. // LookinServer
  4. //
  5. // Created by Li Kai on 2019/10/8.
  6. // https://lookin.work
  7. //
  8. #import "UIBlurEffect+LookinServer.h"
  9. #import "NSObject+Lookin.h"
  10. #import <objc/runtime.h>
  11. @implementation UIBlurEffect (LookinServer)
  12. + (void)load {
  13. static dispatch_once_t onceToken;
  14. dispatch_once(&onceToken, ^{
  15. Method oriMethod = class_getClassMethod([self class], @selector(effectWithStyle:));
  16. Method newMethod = class_getClassMethod([self class], @selector(lks_effectWithStyle:));
  17. method_exchangeImplementations(oriMethod, newMethod);
  18. });
  19. }
  20. + (UIBlurEffect *)lks_effectWithStyle:(UIBlurEffectStyle)style {
  21. id effect = [self lks_effectWithStyle:style];
  22. if ([effect respondsToSelector:@selector(setLks_effectStyleNumber:)]) {
  23. [effect setLks_effectStyleNumber:@(style)];
  24. }
  25. return effect;
  26. }
  27. - (void)setLks_effectStyleNumber:(NSNumber *)lks_effectStyleNumber {
  28. [self lookin_bindObject:lks_effectStyleNumber forKey:@"lks_effectStyleNumber"];
  29. }
  30. - (NSNumber *)lks_effectStyleNumber {
  31. return [self lookin_getBindObjectForKey:@"lks_effectStyleNumber"];
  32. }
  33. @end