我在 tableview 中添加了两个动作领先的滑动动作,但只有背景显示并且标题不可见。
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let card = savedCards[indexPath.row]
// if !card.isDefault{
let makeDefault = UIContextualAction(style: .normal, title: "Make as Default") { (action, sourceView, completionHandler) in
print("index path of default: \(indexPath)")
}
let closeAction = UIContextualAction(style: .normal, title: "Mark as Read", handler: { (ac:UIContextualAction, view:UIView, success:(Bool) -> Void) in
print("CloseAction ...")
success(true)
})
closeAction.backgroundColor = .blue
let swipeActionConfig = UISwipeActionsConfiguration(actions: [makeDefault,closeAction])
swipeActionConfig.performsFirstActionWithFullSwipe = true
return swipeActionConfig
// }
return nil
}