iOS 9 UINavigationController 和 UISearchBar 之间的细线

iOS 9 hairline between UINavigationController and UISearchBar

我有一个 UINavigationController,下面以编程方式放置了一个 UISearchController

searchController.searchBar.barTintColor = UIColor(red: 242/255.0, green: 82/255.0, blue: 46/255.0, alpha: 0.4)
searchController.searchBar.translucent = false
searchController.searchBar.layer.borderColor = UIColor.whiteColor().CGColor
searchController.searchBar.layer.borderWidth = 0

我像上面那样设置 UISearchController。 我像这样全局设置 UINavigationBar 它的设计:

UINavigationBar.appearance().translucent = false
UINavigationBar.appearance().barTintColor = UIColor(red: 242/255.0, green: 82/255.0, blue: 46/255.0, alpha: 1.0)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), forBarPosition: .Any, barMetrics: .Default)
UINavigationBar.appearance().layer.shadowRadius = 0
UINavigationBar.appearance().layer.shadowOpacity = 0
UINavigationBar.appearance().layer.shadowOffset = CGSizeMake(0,0)
UINavigationBar.appearance().titleTextAttributes = [
    NSForegroundColorAttributeName: UIColor.whiteColor(),
    NSFontAttributeName: UIFont(name: "JosefinSans-SemiBold", size: 18)!
]

它应该删除那个 1px 细线边框,但它没有。我读到这是因为阴影图像,但我似乎无法删除 1px 细线。 谁能帮帮我?

尝试替换这个:

searchController.searchBar.layer.borderColor = UIColor.whiteColor().CGColor
searchController.searchBar.layer.borderWidth = 0

有了这个:

searchController.searchBar.layer.borderColor = UIColor(red: 242/255.0, green: 82/255.0, blue: 46/255.0, alpha: 1).CGColor
searchController.searchBar.layer.borderWidth = 1