0

I'm using a UIVisualEffect that applies a blur effect to a UIImageView inside a custom cell for a UICollectionView. This is used as the background of the cell which takes up the whole screen.

    UIVisualEffect *blurEffect;
    blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    self.blurEffect = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    self.blurEffect.frame = self.blurBackground.bounds;

[self.blurBackground addSubview:self.blurEffect];

When I scroll, the frame rate drops a bit until the cell movement stops.

I tried:

cell.layer.shouldRasterize = YES;
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;

but this just makes things worse (I understood why on this thread).

I am using dequeueReusableCellWithReuseIdentifier.

From what I understand, the blur effect is getting re-calculated all the time, so perhaps I can save the blurred image instead of re-rendering it on every frame? Any idea how to do this?

Or any other ideas on how to improve performance?

Community
  • 1
  • 1
Drowned
  • 373
  • 2
  • 12

1 Answers1

0

implement the UIScrollViewDelegate, when -[ scrollViewWillBeginDragging:] remove the blur, and -[scrollViewWillEndDragging:withVelocity:targetContentOffset:] add the blur view again. This may be fine for the scroll animation.

Feng Lin
  • 670
  • 4
  • 8
  • But I need the blur view when scrolling, otherwise it will look bad when the blur gets removed or added. I will upload a screenshot, perhaps it will make things clearer. – Drowned Mar 05 '15 at 16:35
  • Or update the blur view to the background view, just merge two view layer to one , so when scroll just use the merged view to show. No use this render method like your that one. – Feng Lin Mar 06 '15 at 01:29