I have custom collectionview cell (item). I have many UILabels
in each item. Depending on data from server, I want to update the label appropriately. Updating the data by reloading the corresponding item works fine. Code:
isUpdate = YES;
[_collectionView performBatchUpdates:^{
[_collectionView reloadItemsAtIndexPaths:bufferUpdateRow];
} completion:^(BOOL finished) {}];
In the cellForItemAtIndexPath
method, I check for changes, and if there are any, I want to use animation block, but it seems not working.
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellID = @"CellID";
CollectionViewCell *cell = (CollectionViewCell*)[collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
// Update label content here
if (isUpdate) {
_label1.layer.backgroundColor = [UIColor redColor];
[UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^(void) {
_label1.layer.backgroundColor=[UIColor clearColor].CGColor;
} completion:nil];
isUpdate = NO;
}
return cell;
}
The label is not flashing red as I want. Instead it just stay clear. If I remove the animation block, the label becomes red (which shows the updating detection works fine). Pls help