【发布时间】:2017-10-26 10:14:15
【问题描述】:
第一次加载表格视图时看起来不错,但问题是滚动表格视图或重新加载表格视图然后lineView 位置发生变化。
func drowLine(_ cell: UITableViewCell)->UIView{
let lineView = UIView(frame: CGRect(x: 20, y: cell.contentView.frame.size.height - 1.0, width: cell.contentView.frame.size.width - 40 , height: 1))
lineView.backgroundColor = UIColor(red: 56/255, green: 66/255, blue: 72/255, alpha: 0.149)
return lineView
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: titleDisclosureIndicatorID, for: indexPath) as! TitleDisclosureIndicatorCell
//......
cell.contentView.addSubview(drowLine(cell))
return cell
}
class TitleDisclosureIndicatorCell: BaseTableViewCell {
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
}
//.....
}
初始加载表视图:
滚动并重新加载 tableview 行位置后更改一些行:
【问题讨论】:
-
它是如何变化的?
-
@MilanNosáľ 图片已添加
标签: ios swift uitableview swift4