2012-07-25 79 views

回答

1

只需重新实现它:

+ (UIColor *)groupTableViewBackgroundColor { 
    return mySpecialColor; 
} 

,当你做到这一点它会被覆盖。

编辑:这似乎没有一直在努力(尽管它应该这样做!),所以这里的改变方法的返回值的真正准系统方法混写的实现:

#import <objc/runtime.h> 
#import <objc/message.h> 

UIColor *modified(Class __self, SEL __cmd) 
{ 
    return someOtherColor; 
} 

Class clazz = [UIColor class]; 
static IMP original; 
Method m = class_getClassMethod(clazz, @selector(groupTableViewBackgroundColor)); 
original = method_setImplementation(m, (IMP)modified); 

这所有工作都应在初始化期间尽早完成

+0

非常感谢。他们会这样做: – 2012-07-25 18:55:13

+0

tableView.backgroundColor = [UIColor groupTableViewBackgroundColor]; - 但这只是返回默认的背景色。 – 2012-07-25 19:02:46

+0

如果这不起作用(尽管它应该),您可以使用方法swizzling来更改此特定方法的实现。 – 2012-07-25 19:10:32