Achieving a single UIBlurEffect in the main UISplitView
I am using stock UISplitViewController
with pre-made view controllers Master
and Detail
. In the storyboard, I added a controller UIImageView
to the controller Detail
to effectively fill the view with a single image.
In a controller, Master
I used the following to blur the background of that controller:
// In viewDidLoad
self.tableView.backgroundColor = [UIColor clearColor];
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc]
initWithEffect:blurEffect];
self.tableView.backgroundView = visualEffectView;
self.tableView.separatorEffect = [UIVibrancyEffect effectForBlurEffect:blurEffect];
When the controller Master
appears above the controller Detail
, notice how Master
there is a dark shadow at the edges of the controller around the inner edges.
How can you remove those "shadows" to create a uniform blur instead?
More details
Debugging the view hierarchy in IB reveals a view (private?) Called _UIPopoverSlidingChromeView
. It has a gray inset border and is definitely what's responsible for the uneven appearance of the blur.
Disabling preview blur altogether and just leaving it self.tableview.backgroundColor = [UIColor clearColor]
shows a _UIPopoverSlidingChromeView
gray frame. It looks like this:
Any thoughts on how to avoid _UIPopoverSlidingChromeView
when using UISplitViewController
?
source to share
The problem is that this is a private class that you cannot test with.
Fortunately, it _UIPopoverSlidingChromeView
is a subclass UIPopoverBackgroundView
that is publicly available (because in a normal thread implementation thread, the client can customize the focal chrome by creating a class that subclasses UIPopoverBackgroundView
).
for (UIView *subview in self.viewController.view.superview.superview.subviews) {
if ([subview isKindOfClass:[UIPopoverBackgroundView class]]) {
subview.alpha = 0.0;
}
}
It should hide _UIPopoverSlidingChromeView
.
source to share