UITableViewCellAccessoryCheckmark in black?
Is there any easy way to change the color of the "UITableViewCellAccessoryCheckmark" from standard blue to black? Or do i need to make a subclass of uitableviewcell an开发者_如何转开发d insert a imageview myself?
Thanks :-) Sebastian
As far as I know there is no way of doing this.
I ended up implementing a complete custom view for my accessoryView. It also makes it easier to change it upon user interaction and to decide the tappable area, which I often find way to small. I guess you could do with just a button if you have no need for different views.
I did a customView, placed a transparent button inside it. This view I add to the cell:
CustomDisclosureArea *disArea = [[CustomDisclosureArea alloc] init];
[disArea setFrame:CGRectMake(280.0f, 0.0f, 40.0f, 71.0f)];
[disArea setTag:DISCLOSURE_ID];
[disArea.emptyButton addTarget:self action:@selector(cellButtonHandler:event:) forControlEvents:UIControlEventTouchUpInside]; //this the button inside the view.
[cell.contentView addSubview:disArea];
[disArea switchToState:AreaStateBlank]; //I can set it to different states (blank, checkmark, empty etc.
[disArea release];
Now the method that gets called when the accessoryView is tapped is a little special because we need to know which cell was tapped.
- (void) cellButtonHandler:(id)sender event:(id)event {
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint: currentTouchPosition];
}
But You end up with an NSIndexPath, which is the same as you would get in a didSelectRow or and accessoryButtonTapped method.
Hope this helps if You decide to make a custom accessoryView:)
I haven't tried it but it might be possible to simply interrogate the accessoryView
property of the cell and find the checkmark and replace it with another image (it's almost certainly an image.) I think that cell style is just a default style tablecell with an image cell that holds the checkmark.
精彩评论