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

   #import <objc/runtime.h>

    

    

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

    

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

    method_exchangeImplementations(method1, method2);

原文地址:https://www.cnblogs.com/paocai2015/p/5823916.html