NavigationBar 相关

  • 修改Navigation Bar的按钮/文字颜色

在Storyboard中Navigation View Controller Scene,选中Navigation Bar,修改View下的Tint颜色

  • 修改Navigation Bar的背景颜色

修改 Navigation Bar 下的 Bar Tint

  • 解决Push时 Navigation Bar 右上角黑影
self.view.backgroundColor = UIColor.white

  • 某个界面的 Navigation Bar 透明
override func viewDidAppear(_ animated: Bool) {
    self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
}
    
override func viewWillDisappear(_ animated: Bool) {
    self.navigationController?.navigationBar.setBackgroundImage(nil, for: UIBarMetrics.default)
}

  • 上滑隐藏
extension Controller: UIScrollViewDelegate {

    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) {
        if velocity.y > 0 {
            self.navigationController?.setNavigationBarHidden(true, animated: true)
        } else {
            self.navigationController?.setNavigationBarHidden(false, animated: true)
        }
    }

}


你可能感兴趣的:(NavigationBar 相关)