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.
source to share
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 .
source to share
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;
source to share