Adding UIVisualEffectView to background UITableView only works on simulator, not device

I have UITableView

with UIImageView

how backgroundView

. It works like a charm. However, now I am trying to blur this image (using UIVisualEffectView

) to make the tableView background look blurry. However, my code somehow ignores the image and just blurs the white background of the table. Here is the code: Strike>

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 testing, I found this works on the simulator, but not on the device itself. I have attached screenshots below the well. What's even more surprising when I comment [tempImageView addSubview:blurEffectView]

; the image appears. This means that the image is copied to the phone.

Physical Phone

Simulator

+3


source to share


3 answers


This must be one of the dumbest problems I've encountered. Apparently I have turned on "Reduce transparency" in the iphone settings. Hence the problem. Hope this helps another poor soul trying to save battery.



+4


source


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

if (UIAccessibilityIsReduceTransparencyEnabled()) {
   ...
}

      



See this blog post for a more detailed description of UIVisualEffectView

device discovery .

+1


source


try it

 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

-1


source







All Articles