首页 > 代码库 > 拦截方法并替换成自己的方法

拦截方法并替换成自己的方法

   #import <objc/runtime.h>

    

    

    Method method1 = class_getInstanceMethod([self class],@selector(didAddSubview:));

    

    Method method2 = class_getInstanceMethod([self class], @selector(didModifyRange:));

    method_exchangeImplementations(method1, method2);

拦截方法并替换成自己的方法