我意识到iOS 7尚未正式发布,我们不应该讨论它,但是我很想解决这个问题。在iOS 6上,我的表格视图是透明的,看起来很棒。首次运行iOS 7,背景为白色。
我试过将表格backgroundColor,单元格颜色等更改为UIColor clearColor,但没有更改。
如何解决这个问题?

我意识到iOS 7尚未正式发布,我们不应该讨论它,但是我很想解决这个问题。在iOS 6上,我的表格视图是透明的,看起来很棒。首次运行iOS 7,背景为白色。
我试过将表格backgroundColor,单元格颜色等更改为UIColor clearColor,但没有更改。
如何解决这个问题?

Answers:
    // Fix for iOS 7 to clear backgroundColor
    cell.backgroundColor = [UIColor clearColor];
    cell.backgroundView = [[UIView new] autorelease];
    cell.selectedBackgroundView = [[UIView new] autorelease];在cellForRowAtIndexPath中
此外,请确保您的表视图实际上具有透明背景(在情节提要中):

尝试先将backgroundView设置为nil。
[self.tableView setBackgroundView:nil];
[self.tableView setBackgroundColor:[UIColor clearColor]];不知道这是iOS7文档的更改还是一直存在并且只是不影响背景颜色,而是根据UITableView类参考@property backgroundView
“必须将此属性设置为nil才能设置表格视图的背景色。”
编辑:更正后的代码语法
已经回答了这个问题,但是在很多方面都是错误的。
您需要实现以下委托方法:
    - (void)tableView:(UITableView *)tableView  willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [cell setBackgroundColor:[UIColor clearColor]];
}您无法将修复程序放在cellForRowAtIndexPath中,因为那是在渲染单元格之后,并且它将在背景设置为清除之前(在较慢的设备上)闪烁白色背景。
使用此委托方法,您的问题就解决了!
实际上,根据文档(UITableViewCell类参考),更改单元格背景颜色的正式正确位置是不同的:
无论使用预定义单元格还是自定义单元格,都可以使用backgroundView属性或更改继承的backgroundColor属性来更改单元格的背景。在iOS 7中,默认情况下,单元格具有白色背景;在iOS的早期版本中,单元格继承了封闭表格视图的背景色。如果要更改单元格的背景颜色,请在表视图委托的tableView:willDisplayCell:forRowAtIndexPath:方法中进行更改。
试试这个代码片段
cell.contentView.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.5];这仅对我有用,当我为每个单元格编辑了清晰的背景色并为表格本身编辑了清晰的色时。
设置表格的透明颜色:
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    initMenu()
    myTableView.backgroundColor = UIColor.clearColor()
}设置单元格的颜色:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("tablecellid", forIndexPath: indexPath)
    cell.backgroundColor = UIColor.clearColor()
    return cell
}为表视图创建IB出口@IBOutlet弱var yourTable:UITableView!
查看负载
override func viewDidLoad() {
    yourTable.delegate = self
    yourTable.dataSource = self
    yourTable.backgroundColor = UIColor.clearColor()
}如果您想清除Cell的颜色,请在
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    cell.backgroundColor = UIColor.clearColor() 
}在我的情况下,该单元是使用xib创建的。似乎xcode5上的界面生成器无法将clearColor设置为cell.backgroundColor。
我要做的只是确实要设定
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// get the cell from the nib
//then force the backgroundColor
cell.backgroundColor = [UIColor clearColor]
return cell;
}// Fix iOS 7 clear backgroundColor compatibility 
// I Think this two lines only are enough
cell.backgroundColor = [UIColor clearColor];
cell.selectedBackgroundView = [[UIView new] autorelease];组
tableView.backgroundColor = [UIColor clearColor];在viewDidLoad中。
如果这不起作用,请尝试:
tableView.backgroundView = nil;迅速3
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "CustomCell", for: indexPath)
    cell.backgroundColor = .clear
    cell.backgroundView = UIView()
    cell.selectedBackgroundView = UIView()
    return cell
}
backgroundView吗?