1

A while ago I asked a question on how to add more than the standard editActionsForRowAt "delete" button. Thanks to the posted answers, my app now has the 3-button swipe-to-edit functionality like below!

enter image description here

However, with iOS9 came pretty little icons to accompany the text... and now I have a new question, how do I get that functionality?

enter image description here

I've Googled many searches like "Add image to editActionsForRowAt" and found nothing helpful. If you have code, a tutorial link, or anything that could get me headed in the right direction, it would be greatly appreciated.

2
  • 1
    You really should try to improve your google searching skill, try uitableviewrowaction image from your question's answer give a bunch of answers, like this or this Commented Dec 28, 2016 at 2:46
  • you have to create a custom cell for this kind of action . Commented Dec 28, 2016 at 4:20

1 Answer 1

3

One of the comments lead me to using unicode characters! Super helpful as they can be added to your normal string. Unicode characters include things like:

Useful unicode character examples Useful unicode character examples 2 Useful unicode character examples 3

So all you do is pass a string with a unicode character, then a line break (\n), then your button title/text. So the basic syntax looks like:

title: "\u{1234}\n YourText "

For easy reuse (because I have multiple tables) I put the characters I wanted into a struct:

struct cellEditActionIcons {
    static var editAction_Arrow = "\u{2191}"
    static var editAction_Check = "\u{2713}"
    static var editAction_Delete = "\u{2715}"
} 

Then you can create the buttons like this:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    var doneBut = UITableViewRowAction (style: .normal, title: "\(cellEditActionIcons.editAction_Check)\n YourText" { action, index in
        //Do stuff
    }
    doneBut.backgroundColor = myColors.someColor
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.