IOS 8 UITableViewRowAction: Swipe left, images?

I just stumbled upon this new iOS8 API. However, I cannot find a solution if I can use images instead of text and allow scrolling left and right? Is it possible? The only thing I found is the following:

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ // maybe show an action sheet with more options [self.tableView setEditing:NO]; }]; moreAction.backgroundColor = [UIColor blueColor]; UITableViewRowAction *moreAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ [self.tableView setEditing:NO]; }]; moreAction2.backgroundColor = [UIColor blueColor]; UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; }]; return @[deleteAction, moreAction, moreAction2]; } 
+8
ios objective-c uitableview
source share
2 answers

No, I don’t think it’s possible for the correct swipe (with a UITableViewCell, anyway). However, you can use the image for the button by setting the background color using colorWithPatternImage :. The width of the button is apparently determined by the length of the title, so if you want to change the width (and not have a visible name), use a title consisting of as many spaces as possible.

+13
source share

in Swift, it will be:

 deleteAction.backgroundColor = UIColor(patternImage: UIImage(named:"sample")!) 
+5
source share

All Articles