[英]Is it possible to have different separator color for each section in UITableView?
我正在嘗試為每個部分使用不同的分隔符顏色。
這個有可能? 有什么辦法可以做到這一點?
我目前在Objective-C中工作,並且可以通過以下代碼來更改整個UITableView分隔符的顏色:
[self.tableView setSeparatorColor:[UIColor clearColor]];
等待你的答案
采用
cell.separatorInset = UIEdgeInsetsMake(0, tableView.frame.width, 0, 0)
真實的例子
switch dataSource[indexPath.section] {
case .withoutSeparator(_, var elements):
let cell: ServiceCell = tableView.dequeueReusableCell(for: indexPath)
cell.separatorInset = UIEdgeInsetsMake(0, tableView.frame.width, 0, 0)
}
return cell
case let .withSeparator(_, elements, _):
let cell: ZoneCell = tableView.dequeueReusableCell(for: indexPath)
return cell
}
實際上,您可以創建自定義UITableView來幫助完成此任務。 您需要重寫UITableview的drawRect代碼並使之成為可能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.