iOS7 - Change UINavigationBar border color

后端 未结 15 2058
时光取名叫无心
时光取名叫无心 2020-12-07 14:44

Is it possible to change the grey border-bottom color of the UINavigationBar in iOS7?

I already tried to remove to border, but this is not working:

[         


        
15条回答
  •  情深已故
    2020-12-07 15:20

    The only way I found to change color is:

    override func viewDidLoad() {
        super.viewDidLoad()
    
        if let navigationController = self.navigationController {
            let navigationBar = navigationController.navigationBar
            let navigationSeparator = UIView(frame: CGRectMake(0, navigationBar.frame.size.height - 1, navigationBar.frame.size.width, 0.5))
            navigationSeparator.backgroundColor = UIColor.redColor() // Here your custom color
            navigationSeparator.opaque = true
            self.navigationController?.navigationBar.addSubview(navigationSeparator)
        }
    
    }
    

提交回复
热议问题