![](/img/trans.png)
[英]how to automatically slide/swipe the cell tableviewcell swift 3
[英]Swift 3: Swipe to 'Flag', how to
我有一些代碼本質上工作正常。 當我向左滑動時,我看到了標志按鈕,當我點擊按鈕時,字符串“標記按鈕輕敲”被打印到控制台。 所以基礎知識已經到位。
但是......我想將單元格標記為“已標記”,而不是僅將其打印到控制台。 非常像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
。 然后你可以根據你的要求設置它的顏色。 如果您標記某些行,則將此視圖的背景顏色設置為橙色,如果未標記,則將其背景顏色設置為清除顏色!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.