Problem with UIVisualEffectView as background
I wanted to add finaly efficent bluring technique added in iOS8 - UIVisualEffectView to collectionViewCell, but there is something wrong with rendering it in every second cell.
I am not that fluent with layout so I decided to ask you to have a look. I define blur background like this inside cell:
-(void)setupBlurView
{
if ([self.blurEffectView superview]) {
[self.blurEffectView removeFromSuperview];
}
self.blurEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
self.blurEffectView.frame = self.bounds;
[self insertSubview:self.blurEffectView atIndex:0];
}
Any ideas what causes it?
Is this code inside your custom collectionVIewCell ? if so you should probably add the blur effect view into the the contentView of the cell instead of directly inserting it to the cell.
This code is executed in
-(void)layoutSubviews
{
[super layoutSubviews];
[self setupBlurView];
}
of the custom collection view cell using
[collectionView dequeueReusableCellWithReuseIdentifier:@"CustomCell" forIndexPath:indexPath];
The reason why I dare to blame your awesome layout is that when I disable it I don't get this kind of artifacts.
Please have a look at the screenshot.
Bare in mind it happens to every other (1,3,5,7 ...) cell. Maybe there is something diffrent with their apperance?

I see the screen shots and they seem fine to me. But maybe there is something i'm missing. What specifically about the screenshots you posted bothers you ? namely, what do you mean by "artifacts" is it the actual transform ? have you checked out the video, in the readme of the repo, the transforms are part of what makes the layout. But I love how you are using it it with blur views, it makes for an interesting effect
There is strong diffrence between left and right blur view. Left has artifacts (blur is distorted in some kind of wrong way). It looks much worse when you are actually moving it around.
I understand how the layout works and I like 3D transition. Probably I should blame apple for bug in uivisualeffectview.
But I wanted to talk about cell recreation and possible problems which it may cause to uivisualeffectview. As mentioned before turing off the layout makes it work and also simple 3D transitions with uivisualeffectview not cause the problem.
Any idea where to start looking?
I see your point. I'll have to look into it for the layout. However, I'd say that you apply a similar transform (rotation around say the y axis) with different angles and see how the blur effect view behaves.
Here is my test code for 3D transitions of this view. It seem to work fine on every axis.
#import "ViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIVisualEffectView *blurView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
self.blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
self.blurView.frame = CGRectMake(100, 100, 200, 200);
[self.view addSubview:self.blurView];
[self runSpinAnimationOnView:self.blurView duration:1 rotations:1 repeat:INFINITY];
}
- (void) runSpinAnimationOnView:(UIView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}
@end