After searching all over internet for a long time, but not getting the appropriate answer. I am putting the UITableView in editing mode and selecting multiple rows at a time. It is working great, but I wanted to change the color of checkmark from red to blue same as it is in the iPhone email app.
Any help would be appreciated.
Edited Version:
Here is my code...
in my ViewDidLoad function:
- (void)viewDidLoad
{
...
[deviceTableVIew setAllowsSelectionDuringEditing:YES];
[deviceTableVIew setAllowsMultipleSelectionDuringEditing:YES];
[super viewDidLoad];
}
I have two UIButtons whhich set the editing mode for the tableview as follows:
-(IBAction)control:(id)sender{
btnControl.enabled = false;
btnControl.hidden = true;
btnCancel.enabled = true;
btnCancel.hidden = false;
stateToggleToolbar.hidden = false;
[self.deviceTableVIew setEditing:YES animated:YES];
}
-(IBAction)cancel:(id)sender{
btnCancel.enabled = false;
btnCancel.hidden = true;
btnControl.enabled = true;
btnControl.hidden = false;
stateToggleToolbar.hidden = true;
[self.deviceTableVIew setEditing:NO animated:YES];
}
The UITableView delegate methods are:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//setting up the cells here
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
if ([tableView isEditing] == YES) {
// Do Nothing
}else{
[self.navigationController pushViewController:viewController animated:YES];
}
}
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
return 3;
}
One line solution is here)
Just set cell tintColor in your cellForRow:atIndexPath method.
cell.tintColor = UIColor.red
Below is swift code:
func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath)
-> UITableViewCell
{
//get cell to configure from tableView
let cell = tableView.dequeueReusableCellWithIdentifier("myCellIdentifier", forIndexPath: indexPath) as UITableViewCell
//This line will change checkmark color of your awesome cell
cell.tintColor = UIColor.redColor()
// Configure cell
// ...
//work is done! Let put the cell back to the tableView))
return cell
}
And this is the result of selected and not selected cells::
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With