I have an UITableView and I've added edit actions to it. Now I want to add image above the delete buttons label, as:
This is my code:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let blockAction = UITableViewRowAction(style: .Normal, title: "Block") { (rowAction:UITableViewRowAction, indexPath:NSIndexPath) -> Void in
//TODO: Delete the row at indexPath here
}
blockAction.backgroundColor = UIColor.redColor()
return [blockAction]
}
How can I add image on my Delete
button?
You can use special image on background color and use '\n' symbol for let down text
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let blockAction = UITableViewRowAction(style: .normal, title: "\nBlock") { (rowAction:UITableViewRowAction, indexPath:IndexPath) -> Void in
//TODO: Delete the row at indexPath here
}
blockAction.backgroundColor = UIColor(patternImage: UIImage(named: "delete_background")!)
return [blockAction]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With