2

Is there a way to set the selected background color for a cell ? For the moment I'm using this code :

    UIImageView* selectedBackgroundCell = [[[UIImageView alloc] initWithFrame:CGRectNull] autorelease];
    [selectedBackgroundCell setImage:[UIImage imageNamed:@"cell_hover_bg.png"]];
    [cell setSelectedBackgroundView:selectedBackgroundCell];


    [cell setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_bg.png"]]];

and here is the result : enter image description here

Unfortunately, the border doesn't draw well during the selected mode, as I expected. Do you know how to fix this ?

Nielsou Hacken-Bergen
  • 2,606
  • 6
  • 27
  • 37
  • possible duplicate of [How to customize the background/border colors of a grouped table view?](http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view) – rckoenes Aug 22 '11 at 12:43
  • also duplicate of http://stackoverflow.com/questions/281515/how-to-customize-the-background-color-of-a-uitableviewcell – ennuikiller Aug 22 '11 at 12:44
  • not a duplicate. I manage to add a background color, but not a selected background color. Thks – Nielsou Hacken-Bergen Aug 22 '11 at 12:51

1 Answers1

0

As far as I know the only way is to create 2 new images: header and footer, and load them when the requested row is the first or last.

andreamazz
  • 4,256
  • 1
  • 20
  • 36
  • is there a delegate methods which specifies whether or not a cell is selected ? like cellWillBeSelected and cellWillBeUnselected ? – Nielsou Hacken-Bergen Aug 22 '11 at 20:19
  • tableView:willSelectRowAtIndexPath: Check the reference here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html – andreamazz Aug 23 '11 at 06:52
  • unfortunately this methods deosn't implement this comportement. I've already tried it. Thanks for helping. – Nielsou Hacken-Bergen Aug 23 '11 at 09:37