问题描述
我正在使用股票 UISplitViewController
,开箱即用的 Master
和详细信息
查看控制器。在故事板中,我在 Detail
控制器集中添加了 UIImageView
,以便用单个图像有效地填充视图。
I'm using a stock UISplitViewController
with out-of-the-box Master
and Detail
view controllers. In a storyboard, I've added a UIImageView
to the Detail
controller set to effectively fill the view with a single image.
在 Master
控制器中,我使用以下内容模糊了该控制器的背景:
In the Master
controller, I've 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];
当 Master
控制器出现在详细信息
控制器,请注意 Master
控制器边缘内边缘周围是否有阴影。
When the Master
controller appears above the Detail
controller, note how the edges of the Master
controller have a dark shadow around the inner edges.
如何删除这些阴影而不是呈现统一模糊?
How can these "shadows" be removed to instead render a uniform blur?
在IB中调试视图层次结构a(私有?)视图名为 _UIPopoverSlidingChromeView
。它有一个嵌入的灰色框架,它肯定是造成非均匀模糊外观的原因。
Debugging the view hierarchy in IB reveals a (private?) view called _UIPopoverSlidingChromeView
. It has an inset grey frame, and it's definitely what's responsible for the non-uniform blur appearance.
完全禁用模糊视图,只需离开 self.tableview.backgroundColor = [UIColor clearColor]
显示 _UIPopoverSlidingChromeView
的灰框。看起来像这样:
Disabling the blur view altogether and just leaving self.tableview.backgroundColor = [UIColor clearColor]
shows _UIPopoverSlidingChromeView
's grey frame. It looks like this:
在使用 UISplitViewController
时,有关如何避免 _UIPopoverSlidingChromeView
的任何想法?
Any thoughts on how to avoid _UIPopoverSlidingChromeView
when using UISplitViewController
?
推荐答案
问题是它是一个你无法测试的私有类。
The problem is that it is a private class that you can't test against.
幸运的是 _UIPopoverSlidingChromeView
是公共的 UIPopoverBackgroundView
的子类(因为在常规中) popover实现流程客户端可以通过提供一个子类 UIPopoverBackgroundView
)来定制popover背景chrome。
Fortunately _UIPopoverSlidingChromeView
is the subclass of UIPopoverBackgroundView
that is public (because in regular popover implementation flow client may customize the popover background chrome by providing a class which subclasses UIPopoverBackgroundView
).
for (UIView *subview in self.viewController.view.superview.superview.subviews) {
if ([subview isKindOfClass:[UIPopoverBackgroundView class]]) {
subview.alpha = 0.0;
}
}
这应隐藏 _UIPopoverSlidingChromeView
。
这篇关于在UISplitView的主视图中实现统一的UIBlurEffect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!