Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a UITableViewCell's accessory color?

Tags:

ios

iphone

I'd like to set the accessory view icon to be white, similarly to how icons are colored white automatically in a black TabBar, but it's not immediately obvious to me how to do this. Does anyone have experience with this?

like image 477
iand675 Avatar asked Nov 26 '10 03:11

iand675


People also ask

How do I change the color of my disclosure indicator?

You cant change its color by by simply specifying its UIColor. You can customize Disclosure Indicator by adding one image for normal state and another for selected (highlighted).


2 Answers

Actually the correct answer (despite it being so late) is to set your cell tintColor property to a white UIColor object, like so:

UITableViewCell *cell = [UITableViewCell new]; // or other instantiation... [cell setTintColor:[UIColor whiteColor]]; 

Subclassing the accessory view entirely is also possible, but the question is asking to make the cell accessory button white, so this should be the correct answer (at least for iOS7).

Note: Corrected property name, also note that it doesn't actually work for the indicator accessory type

like image 79
JackyJohnson Avatar answered Sep 25 '22 21:09

JackyJohnson


Your best bet is to make an image that you want to put in there and then setting the accessory view to be that image. Here’s Apple's Official Documentation for UITableViewCells.

like image 39
Matt Avatar answered Sep 24 '22 21:09

Matt