How to change the border color below the navigation bar?

前端 未结 6 1930
甜味超标
甜味超标 2020-12-28 19:40

Can anyone advise me on how the border below the navigation bar can be changed?

\"enter

6条回答
  •  不知归路
    2020-12-28 20:28

    In Swift like the @Legolas answer:

    if let navigationController = self.navigationController {
    
       let navigationBar = navigationController.navigationBar     
       let navBorder: UIView = UIView(frame: CGRectMake(0, navigationBar.frame.size.height - 1, navigationBar.frame.size.width, 1))
       // Set the color you want here
       navBorder.backgroundColor = UIColor(red: 0.19, green: 0.19, blue: 0.2, alpha: 1)
       navBorder.opaque = true
       self.navigationController?.navigationBar.addSubview(navBorder)
    }
    

    You can put in the viewDidLoad() of your UIViewController.

提交回复
热议问题