tableView中的ios Separator视图
我在单元格之间添加了分隔符以增加间距 但是当我将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,
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的视图层次结构。