I create a UITableViewController (at the root of the UINavigationController) and present it modally on top of another view controller. It works for me to such an extent that when loading a view and calling viewDidAppear, the visual effect looks good. But immediately after viewDidAppear, the visual effect disappears, and the tableview has a white background.
In my submitted UITableViewController, I added this to viewDidLoad:
if (NSClassFromString(@"UIVisualEffectView") && !UIAccessibilityIsReduceTransparencyEnabled()) { self.tableView.backgroundColor = [UIColor clearColor]; UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]; UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; [blurEffectView setFrame:self.tableView.frame]; self.blurView = blurEffectView; self.tableView.backgroundView = self.blurView; }
I also implement this to make sure the cells have a clear background:
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ if (NSClassFromString(@"UIVisualEffectView") ) { cell.backgroundColor = [UIColor clearColor]; } }
I also set cell.backgroundColor = [UIColor clearColor] in tableView cellForRowAtIndexPath: but that doesn't help either.
Again, I get the correct effect when loading the view, but it loses the blur background as soon as it appears on the screen. Any ideas what could go wrong? I also tried saving blueEffectView as a property in my view controller, but no luck
source share