AJ. AJ. -4 years ago 131
iOS Question

Which is the best way to change the color/view of disclosure indicator accessory view in a table view cell in iOS?

I need to change the color of the

disclosureIndicatorView
accessory in a
UITableViewCell
.
I think there are two ways to get this done, but I'm not able to figure out which one's the optimum. So here is what I think I can do.

There is a property of
UITableViewCell
-
accessoryView
. So I can use
setAccessoryView:(UIView *)view
and pass view as the
UIImageView
holding the image that I want.

I have written an utility class which creates the content view (stuff like background color, adding other stuff, etc) for my cell and I add this content view to the cell in
UITableViewDelegate
. The other option is to draw a
UIImage
overriding the
drawRect
method of
CustomContentView
utility class.

Performing option 1 - I can get the things done the apple way. Just give them the view and they do the rest. But I guess adding a new
UIView
object to every row might turn out to be a heavy object allocation and decreasing the frame rate. As compared to just a
UIImage
object in my
contentView
. I believe
UIImage
is lighter than
UIView
.

Please throw some light people and help me decide over it.

Answer Source

But I guess adding a new UIView object to every row might turn out to be a heavy obj allocation and decreasing the frame rate. As compared to just a UIImage object in my contentView. I believe UIImage is lighter than UIView.

Drawing an image directly will almost certainly have better performance than adding a subview. You have to determine if that extra performance is necessary. I've used a few accessory views for custom disclosure indicators on basic cells and performance was fine. However, if you're already doing custom drawing for the content rect, it might not be that difficult to do the accessory view also.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download