gpt4 book ai didi

ios - 如何仅为第一行更改 UITableView 的分隔符颜色?

转载 作者:行者123 更新时间:2023-11-28 10:48:06 24 4
gpt4 key购买 nike

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

if indexPath.row == 0 {
tableView.separatorColor = UIColor.clear
} else {
tableView.separatorColor = UIColor.blue
}
}

我有上面的代码只更改第一行的分隔符颜色。然而,整个部分本身带有清晰的分色器而不是蓝色。你能帮我解决这个问题吗?任何帮助将不胜感激。谢谢。

最佳答案

不要使用 tableview 默认分隔符。

tableView.separatorColor = UIColor.clear
或者
tableView.separatorStyle = .none

UITableViewCell 中添加一个 1 px 高度的 UIView,给它任何你想要的颜色。如果相同的 UITableViewCell 用于所有表格行,那么您可能可以使用类似 -

seperatorView.hidden = indexPath.row != 0

关于ios - 如何仅为第一行更改 UITableView 的分隔符颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47639779/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com