更改UITableView的背景色
问题描述:
所有页面现在,我可以改变的UITableView的背景色似更改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