Ios tableView单元格左侧为白色
我创建了一个tableView,试图给它一个背景色,但突然出现了一个奇怪的行为。左边是白色而不是我给它的背景色?这是什么原因Ios tableView单元格左侧为白色,ios,objective-c,iphone,uitableview,swift,Ios,Objective C,Iphone,Uitableview,Swift,我创建了一个tableView,试图给它一个背景色,但突然出现了一个奇怪的行为。左边是白色而不是我给它的背景色?这是什么原因 func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forInde
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel?.backgroundColor = UIColor(rgba: "#333843")
cell.textLabel?.font = UIFont(name: "HelveticaNeue", size: 16)
cell.textLabel?.text = "Favoritter"
cell.textLabel?.textColor = UIColor(rgba: "#ffef7c")
return cell
}
您正在文本标签上应用彩色背景 因此,如果要更改单元格的背景,应执行以下操作:
cell.backgroundColor = UIColor(rgba: "#333843")
将背景色应用于contentView。
cell.contentView.backgroundColor = UIColor(rgba: "#333843")
尝试更改inset=0或将单元格背景色更改为当前背景色。我的回答是否解决了问题?如果没有,你可以检查你的故事板或你的xib文件,这个单元可能不会占用所有的容器大小。