1.调用- (void)drawRect:(CGRect)rect方法
- (void)drawRect:(CGRect)rect
{
[[UIImage resizedImage:@"bg_buyBtn.png"] drawInRect:rect];
}
2.第二种方法
#pragma mark 添加一个全屏的背景
- (void)setupBg
{
UIImageView *bg = [[UIImageView alloc] initWithFrame:self.view.bounds];
bg.image = [UIImage imageNamed:is4inch?@"LuckyBackground-568h@2x.jpg":@"LuckyBackground@2x.jpg"];
bg.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:bg];
}
3:第三种方法
// 2.设置背景
self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_tabbar.png"]];
4:tableView设置背景颜色
// 设置背景
tableView.backgroundView = nil;
tableView.backgroundColor = ILGlobalBg;
5:UITableViewCell
#pragma mark 设置背景
- (void)setupBg
{
// 1.默认
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [UIColor whiteColor];
self.backgroundView = bg;
// 2.选中
UIView *selectedBg = [[UIView alloc] init];
selectedBg.backgroundColor = ILColor(237, 233, 218);
self.selectedBackgroundView = selectedBg;
}
浙公网安备 33010602011771号