我有一些本质上工作正常的代码。当我向左滑动时,我会看到标志按钮,当我点击该按钮时,字符串“Flag button tapped”会打印到控制台。所以基础知识已经到位。
但是...我想将单元格标记为“已标记”,而不是仅将其打印到控制台。非常类似于 Iphone 上的 Apple 邮件应用程序,
我使用这个函数来创建滑动按钮:
override func tableView(_ tableView: UITableView, editActionsForRowAt
indexPath: IndexPath) -> [UITableViewRowAction]? {
let flag = UITableViewRowAction(style: .normal, title: "Flag") {
action, index in
print("Flag button tapped")
}
flag.backgroundColor = UIColor.orange
return [flag]
}
关于如何实现这一点有什么想法吗?欢迎任何意见。
最佳答案
您应该在最左侧的单元格中添加一个round view
。然后你可以根据你的要求设置它的颜色。如果您标记某行,则将此 View 的背景色设置为橙色,如果未标记,则将其背景色设置为透明色!
关于ios - swift 3 : Swipe to 'Flag' , 如何,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44021420/