gpt4 book ai didi

ios - UITableViewRowAction 单元格的圆角半径改变背景颜色

转载 作者:行者123 更新时间:2023-11-30 12:54:38 27 4
gpt4 key购买 nike

当 UITableViewRowAction 滑动发生时,与该操作关联的单元格背景会将其背景颜色更改为白色,而不是像通常那样的黑色。换句话说,您可以在单元格圆角半径后面看到的颜色随着滑动操作而变化。请参阅下面的示例图片。

我已经将 View、TableView、Cell 上的所有背景颜色设置为黑色,所以我不确定这种白色是如何显示的。欢迎任何想法或建议!

// Swiping Setup for TableView.
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

let dislikeActivity = UITableViewRowAction(style: .default, title: "Don't Like This") { action, index in
print("dislike button tapped")
}
return [dislikeActivity]

}

Cell with Corner Radius Background is White

最佳答案

为了解决此问题,我在界面构建器 (xib) 中将单元格的背景颜色更改为默认值,并在下面提到的 willDisplay Cell 函数中设置单元格的背景。

func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {

cell.backgroundColor = UIColor(red: 245/255, green: 250/255, blue: 240/255, alpha: 1)

}

在界面生成器中,tableView 的背景仍然设置为黑色。我仍然不确定为什么这样做会起作用,但它确实起作用了,而且即使使用角半径,它现在也能正确显示。

关于ios - UITableViewRowAction 单元格的圆角半径改变背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40569622/

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