Ios 更改所有页面的UITableView背景色

Ios 更改所有页面的UITableView背景色,ios,uitableview,Ios,Uitableview,现在,我可以更改UITableView背景颜色,如 -(void)viewDidLoad { [super viewDidLoad]; [self.tableView setBackgroundView:nil]; [self.tableView setBackgroundView:[[[UIView alloc] init] autorelease]]; [self.tableView setBackgroundColor:[UIColor colorWithPatternImage:

现在,我可以更改UITableView背景颜色,如

-(void)viewDidLoad {
[super viewDidLoad];
[self.tableView setBackgroundView:nil];
  [self.tableView setBackgroundView:[[[UIView alloc] init] autorelease]];
  [self.tableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"tblbg.png"]]];
}
但我需要在所有文件中添加代码。我不想创建UITableView子类


是否可以为UITableView设置类别以更改背景颜色?

似乎是一件很容易尝试的事情

UITableView+CustomBackgroundColor.h:

@interface UITableView (CustomBackgroundColor)

@end
UITableView+CustomBackgroundColor.m:

@implementation UITableView (CustomBackgroundColor)

- (void) viewDidLoad {
    [super viewDidLoad];
    [self.tableView setBackgroundView:nil];
    [self.tableView setBackgroundView:[[[UIView alloc] init] autorelease]];
    [self.tableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"tblbg.png"]]];
}

@end