tableview背景颜色不正确,错误的颜色浮在细胞后面

时间:2013-08-01 07:53:56

标签: iphone ios uitableview

我在代码中拥有的内容:继承自UITableViewController myVC: UITableViewController的类 在.m中使用了xib,即没有dataSource和tableviewDelegates, tableView是一种分组,单元格有白色 我在viewDidLoad

中按照以下方式设置了背景
 [self.tableView setBackgroundView:Nil];
    [self.tableView setBackgroundColor:[UIColor colorWithPatternImage: [UIImage imageNamed: @"App_Background"]]];

也试过了backgroundView

 UIImageView *imgbg = [[UIImageView alloc]initWithFrame:self.tableView.frame];
    imgbg.image =  [UIImage imageNamed: @"App_Background"];
    [self.tableView setBackgroundView:imgbg];

问题:单元格的左右边距有不同的颜色问题图像包含

background floation cell is red arrowed 空白表格图像的是正确的,这就是

的要求

blank table bg is correct required bg 需要bg的表有点像这样也尝试过clearcolor for tableCell,即使那时蓝色浮动单元格bg也没有改变

提前致谢

2 个答案:

答案 0 :(得分:1)

试试这个:

UIView *background = [[UIView alloc] initWithFrame:self.tableView.frame];
background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"App_Background.png"]];
self.tableView.backgroundView = background;

希望它会有所帮助!

答案 1 :(得分:1)

尝试了所有我删除了XIb并使myVC继承自ViewController :UIViewController并以编程方式创建了tableView并将其设置为clearColor为clearcolor和BGView Nil,将viewBackGround设置为我需要的图像,它工作了

但我仍然想知道,为什么它使用XIB工作或从UITableViewController继承

相关问题