3

I have a UITableView with a UIImageView as the backgroundView. This works like a charm. However, now I'm trying to blur this image (using UIVisualEffectView) so that the background of the tableView looks blurred. However, my code somehow ignores the image and simply blurs the white background of the table view. Here is the code:

UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sidebarImage"]];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[blurEffectView setFrame:tempImageView.bounds];
[tempImageView addSubview:blurEffectView];
self.tableView.backgroundView = tempImageView;

EDIT: After some more testing, I found that this works on the simulator, but not on the actual device. I have attached screenshots below a well. What's even more surprising is that when I comment out [tempImageView addSubview:blurEffectView]; the image shows up. That means the image is being copied to the phone.

Physical Phone

Simulator

Sid
  • 1,239
  • 2
  • 13
  • 36
  • Sorry @Sid I've deleted my answer, of course there something I've been mistaken. If you see correctly on the Sim and not on Device is that possible that the image has a different name? Devices are case sensitive, simulators not – Andrea Jul 01 '15 at 13:31
  • 1
    No problem Andrea, the documentation was a bit blurry on this occasion, quite unlike my backgroundview :). Yes, I've checked the imageName. In fact I set up a sample project with just a UIView and turns out it doesn't work in there either. – Sid Jul 01 '15 at 13:34
  • 1
    Figured it out Andrea. Thanks for the help! – Sid Jul 01 '15 at 13:36

3 Answers3

4

This has got to be one of the silliest problems I encountered. Apparently, I had "Reduce Transparency" switched on in my iphone settings. Hence the problem. Hope this helps some other poor soul trying to conserve battery.

Sid
  • 1,239
  • 2
  • 13
  • 36
1

You can detect when "Reduce Transparency" is enabled in iOS 8+ using:

if (UIAccessibilityIsReduceTransparencyEnabled()) {
   ...
}

This blog post goes more in depth on detecting whether UIVisualEffectView is available on a device.

bendytree
  • 13,095
  • 11
  • 75
  • 91
-1

try this

 UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sidebarImage"]];
    UIBlurEffect *blurEffect;
    blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

    UIVisualEffectView * blurEffectView;
    blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];


    blurEffectView.frame = tempImageView.bounds;
    [tempImageView addSubview:blurEffectView];
    self.tableView.backgroundView = tempImageView;

look at this

Community
  • 1
  • 1
Sport
  • 8,570
  • 6
  • 46
  • 65
  • Nope, this code you've posted is functionally identical to what I have above. It does not solve the issue – Sid Jul 01 '15 at 12:54