I working with UICollectionView, and I need add cell dynamically. all cells has blured background view.
When I add item using [self.collectionView insertItemsAtIndexPaths:indexPaths];
I have a trouble with animation cell appear. I see cells content before blur effect has applied to cell's background view.
- (SomeCollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
PKMainMenuCVCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
[self addBlurLayerToCell:cell];
cell.textLabel.text = @"SomeText";
return cell;
}
I have addBlurLayerToCell with dispatch_async, but has no effect.
-(void)addBlurLayerToCell: (SomeCollectionViewCell*) cell
{
dispatch_async(dispatch_get_main_queue(), ^{
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];//];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
blurEffectView.frame = cell.bounds;
blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[cell insertSubview:blurEffectView atIndex:0];
});
}