Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of detail disclosure button for table cell

I want to change the color of detail disclosure button of a table cell. Thanks in advance.

like image 250
rdp Avatar asked Jan 11 '11 07:01

rdp


2 Answers

You have to create a custom UIButton and set it as cell's accessoryView.

Your cellForRowAtIndexPath: will look something like the following,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    //...

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil] autorelease];

        UIButton *myAccessoryButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 24, 24)];
        [myAccessoryButton setBackgroundColor:[UIColor clearColor]];
        [myAccessoryButton setImage:[UIImage imageNamed:@"my_red_accessory_image"] forState:UIControlStateNormal];
        [cell setAccessoryView:myAccessoryButton];
        [myAccessoryButton release];

        //...
    }

    //...
}
like image 166
EmptyStack Avatar answered Sep 27 '22 17:09

EmptyStack


Change the tint of your tableview and cell will work too.

like image 37
fuiiii Avatar answered Sep 27 '22 16:09

fuiiii