Animando el cambio al color de fondo de uitableviewcell

When a cell is selected from a table view, I'd like the cell's background color to change from white (or clear) to black and I'd like the change in color to be animated. Is this possible?

I know certain tricks are necessary to change the background color of a uitableview cell, and I understand those for the most part, but I'd like to take it one step further and animate the change of the cell's background color. I'm assuming this will be done in the didSelectRowAtIndexPath: method.

preguntado el 09 de marzo de 12 a las 22:03

Esto es para un UILabel, but it should get the point across. -

2 Respuestas

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.8];
    [self.tableView cellForRowAtIndexPath:indexPath].imageView.alpha = 1.0;
    [self.tableView cellForRowAtIndexPath:indexPath].backgroundColor=[UIColor redColor];

    [UIView commitAnimations];   

Respondido 03 Oct 12, 10:10

Well as of my knowledge, we cant animate the color change. What we can do , is to play a trick to change colors with a timer. The idea is, given two colors, startColor and endColor, one can easily find the in-between colors (lets say 20). And then using NSTimer we can set color property to each different color after regular intervals. This way, we can have a smooth transition/animation from startColor to endColor.

If anybody requires a code, then i can provide code also for this.

respondido 12 mar '12, 12:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.