Skip to content
This repository was archived by the owner on Jun 13, 2021. It is now read-only.
This repository was archived by the owner on Jun 13, 2021. It is now read-only.

No gradient with tableView editActionsForRowAt #232

@hellonoko

Description

@hellonoko

I was trying to do the following:

override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
        
        let delete = UITableViewRowAction(style: .normal, title: "Delete") { action, index in
            print("delete button tapped")
            
            if let item = self.categories?[indexPath.row] {
                do {
                    try self.realm.write {
                        //check mark on off
                        //item.done = !item.done
                        
                        //delete it when done
                        self.realm.delete(item)
                    }
                } catch {
                    print("Error saving done satus\(error)")
                }
            }
            
            tableView.reloadData()
            
            tableView.deselectRow(at: indexPath, animated: true)
        }
        
        //delete.backgroundColor = .red
        
        let purpleColor = UIColor(red:0.99, green:0.00, blue:0.95, alpha:1.0)
        let greenColor = UIColor(red:0.00, green:0.99, blue:0.22, alpha:1.0)
        
        let colorArray = [purpleColor,greenColor]
        
        delete.backgroundColor = UIColor(gradientStyle: UIGradientStyle.leftToRight, withFrame: delete.accessibilityFrame, andColors: [purpleColor,greenColor])

        return [delete]
    }

And make the swipe to delete background color of my row edit action be a gradient just for fun it does not seem to work. Instead it is a default? grey color.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions