How to set clear background in table view cell swipe action?(如何在表格视图单元格滑动动作中设置清晰的背景?)
问题描述
我在UITableViewCell中有一个trailingSwipeAction,其背景色必须清晰。
这是我设置操作的代码:
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let myAction = UIContextualAction.init(style: .normal, title: nil) {
// My action code
}
myAction.backgroundColor = .clear
myAction.image = UIImage.init(named: "my-icon")
return UISwipeActionsConfiguration.init(actions: [myAction])
}
但我的操作背景为灰色,而不需要任何颜色:
推荐答案
您可以只将操作的背景色的Alpha值设置为0:
let modifyAction = UIContextualAction(style: .normal, title: "", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
print("Update action ...")
success(true)
})
modifyAction.backgroundColor = UIColor.init(red: 0/255.0, green: 0/255.0, blue: 0/255.0, alpha: 0.0)
这篇关于如何在表格视图单元格滑动动作中设置清晰的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!