8

A quick question, I want to change the color of the UITableViewCellAccessoryDisclosureIndicator (the arrow on the right side of tableView) from default gray to white color.

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
KlimczakM
  • 12,576
  • 11
  • 64
  • 83
kingston
  • 1,553
  • 4
  • 22
  • 42
  • Old question but had no satisfactory answer yet. Here is what you *actually* asked for: http://stackoverflow.com/a/35427683/378024 – gblazex Feb 16 '16 at 08:59

5 Answers5

15

You should create an image and use it instead!

cell. accessoryView = myAccessoryUIImageView;

prakash
  • 58,901
  • 25
  • 93
  • 115
  • is der any way to change the UITableViewCellAccessoryDisclosureIndicato color in iphone by default – kingston May 17 '11 at 06:09
  • 1
    i doubt it is possible to change by default. You could subclass UITableViewCell and customize all and maybe reuse that everywhere else? – prakash May 17 '11 at 06:19
  • **It is possible to color the original Apple indicator:** See my answer: http://stackoverflow.com/a/35427683/378024 (without using custom images or custom drawing code) – gblazex Feb 16 '16 at 08:58
4

To change the colour of UITableViewCellAccessoryDetailDisclosureButton:

cell.tintColor = [UIColor whiteColor];
mattsven
  • 22,305
  • 11
  • 68
  • 104
Naloiko Eugene
  • 2,453
  • 1
  • 28
  • 18
  • 3
    The answer may be "right" but it sadly doesn't answer the question that was asked. UITableViewCellAccessoryDisclosureIndicator is not the same as UITableViewCellAccessoryDetailDisclosureButton. :( – Alex Shepard Mar 18 '14 at 19:40
  • UITableViewCell has no such method tintColor – Praveen-K Sep 20 '14 at 10:34
3

For others who are still stumbling upon this question, here's how to do it programmatically.

Create a UIView subclass, and override drawRect: with the following:

#define PADDING 4.f //give the canvas some padding so the ends and joints of the lines can be drawn with a mitered joint

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor);
    CGContextSetLineWidth(context, 3.f);
    CGContextSetLineJoin(context, kCGLineJoinMiter);

    CGContextMoveToPoint(context, PADDING, PADDING);
    CGContextAddLineToPoint(context, self.frame.size.width - PADDING, self.frame.size.height/2);
    CGContextAddLineToPoint(context, PADDING, self.frame.size.height - PADDING);

    CGContextStrokePath(context);
}

This draws a stock indicator arrow. From here you can change the color, line width, etc.

To add the indicator view to your cell:

#define ACCESSORY_WIDTH 13.f
#define ACCESSORY_HEIGHT 18.f

cell.accessoryView = [[AccessoryIndicatorView alloc] initWithFrame:CGRectMake(self.frame.size.width - ACCESSORY_WIDTH - CELL_PADDING, self.frame.size.height/2 - ACCESSORY_HEIGHT/2, ACCESSORY_WIDTH, ACCESSORY_HEIGHT)];
lobianco
  • 6,226
  • 2
  • 33
  • 48
2

You'll find including MSCellAccessory will help in a lot of different ways including changing the color of the UITableViewCellAccessoryDetailDisclosureButton

RobCroll
  • 2,571
  • 1
  • 26
  • 36