简体   繁体   English

消除UINavigationBar和UIVisualEffectView之间的独特模糊边缘

[英]Eliminating a distinctive blur edge between UINavigationBar and UIVisualEffectView

Currently, my view hierarchy consists of a UIViewController (NOT UITableViewController), a UITableView nested in the view controller and a UIVisualEffectView (set to Extra Light) in front of the UITableView, aligned to the bottom of a UINavigationBar. 目前,我的视图层次结构包括一个UIViewController(NOT UITableViewController),一个嵌套在视图控制器中的UITableView和一个位于UITableView前面的UIVisualEffectView(设置为Extra Light),与UINavigationBar的底部对齐。 The effect I want to achieve is somewhat similar to that of the App Store's segmented view. 我想要实现的效果有点类似于App Store的分段视图。

However, I noticed a weird blur edge occurring at the boundary between the navigation bar and the UIVisualEffectView that makes the view look inconsistent, as pictured below (highlighted by the red circle): 但是,我注意到在导航栏和UIVisualEffectView之间的边界处出现了一个奇怪的模糊边缘,使视图看起来不一致,如下图所示(由红色圆圈突出显示):

在此输入图像描述

Optimally, I would prefer that the UIVisualEffectView blends perfectly with the UINavigationBar's blur. 最理想的是,我更喜欢UIVisualEffectView与UINavigationBar的模糊完美融合。

Thanks. 谢谢。

Try to use a UIToolBar instead of a UIVisualEffectView as the background of the segment. 尝试使用UIToolBar而不是UIVisualEffectView作为细分的背景。 The navigation bar has translucent background rather than blur effect. 导航栏具有半透明背景而非模糊效果。 UIToolBar has the same translucent background as navigation bar, so it would look seamless at the edge. UIToolBar具有与导航栏相同的半透明背景,因此它在边缘看起来是无缝的。

Looking to your picture it seems your issue is not attributable to UINavigationBar but to a view where you have added UISegmentedControl . 看你的图片似乎你的问题不是归因于UINavigationBar而是归因于你添加了UISegmentedControl的视图。 I don't know your structure but it could be the tableHeaderView ( self.tableView.tableHeaderView ) so a reasonable way to solve this problem is to change the header color: 我不知道你的结构,但它可能是tableHeaderViewself.tableView.tableHeaderView )所以解决这个问题的合理方法是更改​​标题颜色:

Code example : 代码示例

override func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
        var headerView: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
        header.contentView.backgroundColor = UIColor.clearColor()
        return header
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM