@implementation UIScrollView (Swizz)
+ (void)load {
SEL originalSelector = @selector(setMj_header:);
SEL swizzledSelector = @selector(nr_setMj_header:);
Method originalMethod = class_getInstanceMethod(self.class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(self.class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(self.class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(self.class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
}else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
- (void)nr_setMj_header:(MJRefreshHeader *)mj_header {
@weakify(mj_header)
[RACObserve(mj_header, state) subscribeNext:^(id _Nullable x) {
@strongify(mj_header)
if (mj_header.state == MJRefreshStatePulling) {
AudioServicesPlaySystemSound(1519);
}
}];
[self nr_setMj_header:mj_header];
}
Created
July 31, 2018 10:07
-
-
Save liuzhida33/d07a62bbb3bbe0c56ec29d03ce2988f7 to your computer and use it in GitHub Desktop.
hook mj_header 添加下拉刷新震动
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment