iOS 全局设置背景色方法

#import "UIViewController+AOP.h"
#import 

@implementation UIViewController (AOP)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Method originalMethod = class_getInstanceMethod(self, @selector(viewDidLoad));
        Method swizzledMethod = class_getInstanceMethod(self, @selector(tj_viewDidLoad));
        method_exchangeImplementations(originalMethod, swizzledMethod);
    });
    
}

- (void)tj_viewDidLoad {
    // 全局样式
    [self tj_viewDidLoad];
    //  UIInputWindowController 会覆盖每一个控制器,避免为其设置颜色
    Class class = NSClassFromString(@"UIInputWindowController");
    if (self.class != class) {
        self.view.backgroundColor = [UIColor lightGrayColor];
    }
    CLog(@"%@",self);
}

@end

你可能感兴趣的:(iOS 全局设置背景色方法)