【问题标题】:iOS 9 hairline between UINavigationController and UISearchBarUINavigationController 和 UISearchBar 之间的 iOS 9 细线
【发布时间】:2016-01-18 15:33:45
【问题描述】:

我有一个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 的细线。 谁能帮帮我?

【问题讨论】:

  • 我也有同样的问题。如果您找到解决方案,请标记我!
  • @AnnabelleSykes 答案如下:)

标签: ios swift2 uinavigationbar ios9 uisearchcontroller


【解决方案1】:

尝试替换这个:

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

【讨论】:

  • 是的,修好了!谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-30
  • 1970-01-01
  • 1970-01-01
  • 2011-06-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多