Marco
Marco

Reputation: 1061

Swift - Tableviewcell delete icon custom

is it possibile to set the left icon (when deleting a row in tableviewcell) to a custom image?

delete icon

Thanks :)

Upvotes: 0

Views: 1585

Answers (1)

Pushpendra
Pushpendra

Reputation: 1521

Please try the below code into your Your Controller

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
    let button1 = UITableViewRowAction(style: .default, title: "Your Title If You Want") { action, indexPath in
        print("button1 pressed!")
    }
    if let image = UIImage(named: "yourImage.png"){
        button1.backgroundColor = UIColor(patternImage: image)
    }
    return [button1]
}

Upvotes: 2

Related Questions