Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios tableView单元格左侧为白色_Ios_Objective C_Iphone_Uitableview_Swift - Fatal编程技术网

Ios 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

我创建了一个tableView,试图给它一个背景色,但突然出现了一个奇怪的行为。左边是白色而不是我给它的背景色?这是什么原因

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文件,这个单元可能不会占用所有的容器大小。