Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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
tableView中的ios Separator视图_Ios_Swift_Uitableview - Fatal编程技术网

tableView中的ios Separator视图

tableView中的ios Separator视图,ios,swift,uitableview,Ios,Swift,Uitableview,我在单元格之间添加了分隔符以增加间距 但是当我将separator视图的颜色从blueColor更改为clearColor时,它会消失,有人能帮忙吗 这是我的密码: func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return 50 } func tableView(tableView: UITableView,

我在单元格之间添加了分隔符以增加间距

但是当我将separator视图的颜色从
blueColor
更改为
clearColor
时,它会消失,有人能帮忙吗

这是我的密码:

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
        return 50
    }

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath: indexPath)
    cell.textLabel?.text = "Hello World"
    cell.textLabel?.textColor = UIColor.blackColor()
    cell.backgroundColor = UIColor.clearColor()

    let additionalSeperatorThickness = CGFloat(6)
    let additionalSeperator = UIView(frame: CGRectMake(0,
        cell.frame.size.height - additionalSeperatorThickness,
        cell.frame.size.width,
        additionalSeperatorThickness))
    additionalSeperator.backgroundColor = UIColor.clearColor()
    cell.addSubview(additionalSeperator)

   let imageView = UIImageView(image: UIImage(named: "text_box_1_converted.png")!)
    cell.backgroundView = imageView
    cell.bringSubviewToFront(additionalSeperator)

    return cell

}

最好在TabLieView Calas中提出自己的观点,穆罕默德建议我将一个包含的视图添加到单元格中,然后将图像添加到它。每次单元格被删除时,您都会添加一个子视图,并且从不删除它们。由于单元格在每次屏幕外滚动时都会重复使用,因此您会不断添加额外的子视图。这就是为什么在不保留对子视图的任何引用时,您应该创建自己的类,而不是操纵UITableViewCell的视图层次结构。