Animate backgroundColor UITableViewCell with an accessory

I am currently working on a UITableViewController. In the cells of his UITableView, he presents real-time data from a web service. When one of the basic data elements is updated (every two minutes or so), I want the cell to “instantly” start, so the user understands that the data for this cell has just been updated.

So far I have used this code:

[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^
{
    cell.contentView.backgroundColor = flashColor;
} completion:^(BOOL finished)
{
    [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^
    {
        cell.contentView.backgroundColor = [UIColor clearColor];
    } completion: NULL];
}];

This worked fine until I wanted to give the user the opportunity to “look inside” the data for a given cell and add disclosure indicators. Since the content area is reduced using the framework to make room for the Disclosure indicator, now the flash only highlights the left 90% of the cell, but the background color of the Disclosure indicator does not change.

cell.accessoryView.backgroundColor = flashColor;

and

cell.backgroundView.backgroundColor = flashColor;

won't help fix the animation.

I read about - (void) setHighlighted: (BOOL)highlighted animated: (BOOL)animated, but this will not return the highlighted state immediately after the flash, unless I write most of the unpleasant error-prone code that causes it to not crash. In addition, I will not have any control over the animation itself.

Is there a way to keep the old animation effect with an additional representation, or do I need to start making flash using the selection method?

,

+3
1
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^
{
    [cell setHighlighted:YES animated:YES];
} completion:^(BOOL finished)
{
    [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveEaseInOut animations:^
    {
        [cell setHighlighted:NO animated:YES];
    } completion: NULL];
}];

, , animateWithDuration, iOS 0,2 . 0.2.

, , , ( ). , , , .

!

+6

All Articles