I have set an action for "add to cart" at leading side of the UItableViewCell. I have set background colour, its image and title. below's my code.
@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let addToCart = UIContextualAction(style: .normal, title: "Add to Cart") { (action, view, nil) in
print("Added to cart")
}
addToCart.title = "Add to Cart"
addToCart.backgroundColor = #colorLiteral(red: 0.2196078449, green: 0.007843137719, blue: 0.8549019694, alpha: 1)
addToCart.image = UIImage(named: "cart")
return UISwipeActionsConfiguration(actions: [addToCart])
}
previous attempts : I have not defined title using addToCart.title = "Add to Cart"
but, after not getting it, I have set that.
The image I have added is of 25*25 of size, has clear background and is of .png format.
Try this
Add swipe to delete UITableViewCell
its the bug in UIContextualAction. It does not show both image and title at the same time unless the table view cell height is 91 points. for more info you get forums.apple