Reputation: 1436
I have a tableView with a few cells that have a black background color. On tapping the Edit Button in the navigation Bar, I would like to change the background color of area that allows re-ordering to black instead of the current white color that it shows?
I am able to change the edit button to Done using the function below but I am not sure how to change that specific area of the cells. I sense this is where I change it but i am not show how.
override func setEditing (editing:Bool, animated:Bool)
{
super.setEditing(editing,animated:animated)
if (self.editing) {
self.editButton.title = "Done"
self.navigationItem.setHidesBackButton(true, animated: true)
} else {
self.editButton.title = "Edit"
self.navigationItem.setHidesBackButton(false, animated: false)
}
}
This is the image of what I am referring to.
Upvotes: 2
Views: 1278
Reputation: 11
public class MyTableSource : UITableViewSource
{
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
// abbreviation
// :
// :
cell.BackgroundColor = UIColor.Black;
return cell;
}
}
Upvotes: 1
Reputation: 1436
It turns out setting the cell's background color in code i.e. cellForRowAtIndexPath got the color to uniformly change to black. I had originally done this from the UITableViewCell XIB file used.
Upvotes: 0
Reputation: 334
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
}
In this "swipe to delete" mode the table view does not display any insertion, deletion, and reordering controls. This method gives the delegate an opportunity to adjust the application's user interface to editing mode.
according to the comment you want to capture the event when user does not delete the cell but swipe to end the editing mode. For this, we have the following delegate:
- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = originalColor;
}
Upvotes: 2