標籤:action path round col and 分享 can func dex
// 響應儲存格右滑手勢override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let actionShare = UITableViewRowAction(style: .normal, title: "分享") { (_,IndexPath) in // 定義滑動菜單樣式和標題 let actionSheet = UIAlertController(title: "分享到", message: nil, preferredStyle: .actionSheet) // 定義按鈕 let optionQQ = UIAlertAction(title: "QQ", style: .default, handler: nil) let optionWeiXin = UIAlertAction(title: "", style: .default, handler: nil) let optionCancel = UIAlertAction(title: "取消", style: .cancel, handler: nil) // 把option操作添加到actionSheet中 actionSheet.addAction(optionQQ) actionSheet.addAction(optionWeiXin) actionSheet.addAction(optionCancel) // 顯示 self.present(actionSheet, animated: true, completion: nil) } // 配置按鈕顏色 actionShare.backgroundColor = UIColor.orange let actionDel = UITableViewRowAction(style: .destructive, title: "刪除") { (_, IndexPath) in // 刪除相對應的每行資料 self.areaImages.remove(at: indexPath.row) self.areaProvice.remove(at: indexPath.row) self.areas.remove(at: indexPath.row) self.areaType.remove(at: indexPath.row) self.visted.remove(at: indexPath.row) // Delete the row from the data source tableView.deleteRows(at: [indexPath], with: .fade) } let actionTop = UITableViewRowAction(style: .default, title: "置頂") { (_, _) in } actionTop.backgroundColor=UIColor(red: 245/255, green: 199/255, blue: 221/255, alpha: 1) // 返回滑動子功能表數組 return [actionShare,actionDel,actionTop] }
iOS筆記【儲存格右滑手勢】 2017-09-09