Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the color of UITableViewCellAccessoryDisclosureIndicator

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;
like image 517
kingston Avatar asked May 17 '11 05:05

kingston


2 Answers

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)];
like image 185
lobianco Avatar answered Oct 12 '22 00:10

lobianco


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

like image 34
RobCroll Avatar answered Oct 12 '22 01:10

RobCroll