cell.indentationLevel = 1 // Your indentation level
UPDATE
@IBOutlet weak var tblView: UITableView!
let tblData:[[String:Any]] = [["title":"Category", "indentationLevel":0],
["title":"Name 1", "indentationLevel":1],
["title":"Image1.png", "indentationLevel":2],
["title":"Name 2", "indentationLevel":1],
["title":"Image2.png", "indentationLevel":2]]
// UITableView delegate methods
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tblData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
cell?.textLabel?.text = tblData[indexPath.row]["title"] as? String ?? "NA"
cell?.indentationWidth = 10
cell?.indentationLevel = tblData[indexPath.row]["indentationLevel"] as? Int ?? 0
return cell!
}
注:
您可以使用plist中,而不是存儲字典的數組的靜態數據
爲什麼不顯示像https://github.com/Augustyniak/FileExplorer,級別是單獨的tableview –