我有一个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

关于ios - UINavigationController和UISearchBar之间的iOS 9发际线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34858439/

10-08 20:45