1

Is there a way to turn the default UITableViewCellAccessoryDetailDisclosureButton accessory button from blue colour to black colour?

pdobb
  • 17,688
  • 5
  • 59
  • 74
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256

3 Answers3

13

There isn't a "standard" black one, but it's not that much work to do what you're asking.

Create (in photoshop or something similar) your own black version of the detail disclosure button. You can screen grab and colour it in if that's easier. Then add it as a resource to your project and put it inside a UIImage like so:

UIImage myImage = [UIImage imageNamed:@"blackbutton.png"];

Then create a UIImageView which contains that image:

UIImageView *imageView = [[UIImageView alloc] initWithImage:myImage];

Finally then you can assign that to the "accessory view" for the cell you've set up already:

[cell setAccessoryView:imageView];

Hope that helps!

//EDIT - I felt like having a quick 5 mins in photoshop so created a black one for you. have fun!

removed dead ImageShack link

SuperBiasedMan
  • 9,814
  • 10
  • 45
  • 73
h4xxr
  • 11,385
  • 1
  • 39
  • 36
1

The answer from h4xxr didn't completely work for me in iOS 5.1.1 (clicking on the accessory view didn't call the tableView:accessoryButtonTappedForRowWithIndexPath method), so I altered his solution with help from this related answer, using a UIButton with the image rather than a UIView, which can call a custom selector if clicked:

UIImage *myImage = [UIImage imageNamed:@"blackaccessorybutton.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, myImage.size.width, myImage.size.height);
[button setImage:myImage forState:UIControlStateNormal];
[button addTarget: self
           action: @selector(toggleCustomDetailDisclosureButton:)
 forControlEvents: UIControlEventTouchUpInside];
[cell setAccessoryView:button];
Community
  • 1
  • 1
newenglander
  • 2,019
  • 24
  • 55
1

There is a much easier solution on iOS7. Use the tintColor property on UIView. Subclasses generally tend to respect it, and the disclosure indicator is no exception.

UIView *v = [[cell subviews] lastObject];
        v = v.subviews.count ? [v.subviews objectAtIndex:0] : nil; // v is the disclosure indicator
        if ([v respondsToSelector:@selector(setTintColor:)])
            v.tintColor = [UIColor greenColor];
Morrowless
  • 6,856
  • 11
  • 51
  • 81