gpt4 book ai didi

Swift 3 删除导航栏下方的行

转载 作者:搜寻专家 更新时间:2023-11-01 05:56:20 29 4
gpt4 key购买 nike

当我的项目使用 Swift 2 时,我的代码有效:

extension UINavigationController {
func hairLine(hide: Bool) {
//hides hairline at the bottom of the navigationbar

for subview in self.navigationBar.subviews {
if subview.isKind(of: UIImageView.self) {
for hairline in subview.subviews {
if hairline.isKind(of: UIImageView.self) && hairline.bounds.height <= 1.0 {
hairline.isHidden = hide
}
}
}
}
}

但是现在有些东西变了,它不起作用了。不确定是因为 Swift 3 还是 iOS10,或者我现在正在用 7plus 和 6s 进行测试,但它不再有效。我会在其中调用正在显示的 View Controller 的 viewWillAppear。我在这里看到一个回答说要使用

    UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)

但这并没有奏效。我尝试用这两行替换我旧的 hairLine() 的内容,尝试将它们直接放在 viewWillAppear 和 viewDidAppear 中,但仍然对我不起作用。

最佳答案

试试这个

self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")

关于Swift 3 删除导航栏下方的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42195458/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com