-1

I have added two actions in tableview leading swipe action , but only the background is showing and title is not visible.

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

}

enter image description here

ajith Kumark
  • 333
  • 1
  • 3
  • 16

1 Answers1

0
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

            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

}

enter image description here

Ruchi
  • 109
  • 2