增加細胞之間的空間在一節,我需要在每個部分每個單元之間添加填充使空間SWIFT 2.1斯威夫特2
但我設法做的是增加頭部對此我不想節那。
如何在動態表格單元格之間添加空格?
這裏是增加頭部代碼:
// Set the spacing between sections
override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 10
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let header = UIView()
header.backgroundColor = UIColor.clearColor()
return header
}
下面是創建表視圖代碼:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//Table view cells are reused and should be dequeued using a cell identifier.
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
let rowData = self.tableData[indexPath.row]
cell.textLabel!.text = rowData.name
cell.textLabel!.textAlignment = .Right
if let url = NSURL(string: rowData.img),
data = NSData(contentsOfURL: url)
{
cell.imageView?.image = UIImage(data: data)
}
return cell
}
現在我的表視圖是這樣的:
更新代碼和表格視圖:
哪裏應該是空間?每個細胞之間? – ChikabuZ
你想增加兩個單元格之間的空間嗎? –
@ChikabuZ我想在兩個單元格之間添加空格 – anonymox